2012-11-04 78 views
1

即時通訊設法編寫一個代碼,其中一個文本將出現在可以在fancybox之外看到的div內,當用戶點擊fancybox內的一個選項後(在選擇選項的fancybox將關閉)FancyBox和自動加載文件從fancybox退出

這裏是我的代碼

的index.php

<?php 
session_start(); 
include('connect.php'); 
include('header.php'); 
?> 

<body> 
<a href="selectfield.php" id="selectfield" class="fancybox.iframe" rel="group">Field</a>: 
<span id="selectedfield_label"></span> 
</body> 
</html> 

selectfield.php

<?php 
include('connect.php'); 
include('header.php'); 
?> 

</head> 
<body> 
<div class="row"> 
<div class="span12"> 
<?php 
$searchcol = mysql_query("SELECT * from searchcolumn"); 
while($search = mysql_fetch_array($searchcol)){ ?> 
<div class="span2" style="font-size:10px"> 
<a href="#" id="<?php echo $search['scol_id']; ?>" class="field" name="<?php echo $search['scol_id']; ?>"><?php echo $search['advsearch_name']; ?></a> 
</div> 
<?php 
} 
?> 
</div> 

</body> 
</html> 

的script.js

$(document).ready(function(){ 

$("#selectfield").fancybox(); 
$("#selectcondition").fancybox(); 

$(".field").click(function(e) { 
    var id = this.id; 
    var name = $("#" + id).attr("name"); 
    var datastr='field='+name; 
     $.ajax({ 
      url:'storefield.php', 
      type:"POST", 
      data:datastr, 
      dataType:"json", 
      success:function(result){ 
       $("#selectedfield_label").html(result['field']['fieldname']); 
       parent.$.fancybox.close(true); 
       }//success   
     });//ajax 
    });  
}); 

storefield.php

​​

我能拿到的fancybox關閉時選擇一個選項,但我不能得到它的名字($結果[ '字段'] [「字段名」])到一個div內出現在我的fancybox以外

香港專業教育學院已經嘗試過不同的組合,但我不能讓它的工作

在此先感謝

這裏是一個示例SQL數據

INSERT INTO searchcolumn (advsearch_name,advsearch_col,advsearch_type) VALUES ('Title','title','varchar'); 
INSERT INTO searchcolumn (advsearch_name,advsearch_col,advsearch_type) VALUES ('Last Name','ln','varchar'); 
INSERT INTO searchcolumn (advsearch_name,advsearch_col,advsearch_type) VALUES ('First Name','fn','varchar'); 
INSERT INTO searchcolumn (advsearch_name,advsearch_col,advsearch_type) VALUES ('Middle Name','mn','varchar'); 
INSERT INTO searchcolumn (advsearch_name,advsearch_col,advsearch_type) VALUES ('Gender','gender','varchar'); 
INSERT INTO searchcolumn (advsearch_name,advsearch_col,advsearch_type) VALUES ('Age','age','varchar'); 
INSERT INTO searchcolumn (advsearch_name,advsearch_col,advsearch_type) VALUES ('Birthdate','bday','date'); 

回答

2

你的fancybox可能是在iframe中,所以你必須使用父頁面找到你的DIV要寫出你的結果

parent.$("#selectedfield_label").html(result['field']['fieldname']);