1.父页面
function chooseTopic(btn) {//选择议题
$.fancybox({
type : 'iframe',
href : '',
fitToView : false,
width : '800',
height : '420',
overlayShow : false,
autoSize : false,
closeClick : false,
openEffect : 'none',
closeEffect : 'none',
beforeClose : function() {
var topicId = $(".fancybox-iframe").contents().find("#topicId").val();传递子页面的数值
var topicName = $(".fancybox-iframe").contents().find("#topicName").val();传递子页面的数值
$(btn).val(topicName);
}
});
}
2.子页面
<form >
<table style="margin-top: 4px; width: 98%; height: 100%;" >
<thead>
<tr>
<th>序号</th>
<th >议题名称</th>
</tr>
</thead>
<tbody >
<c:forEach var="vft" items="${VoteFormTopices}" varStatus="status">
<tr>
<td style="text-align: center;" id="sortIndex" >${status.index + 1}</td>
<td ><a href="#" onclick="javascript:chooseTopic(this);" topicId="${vft.topic.id}"
topicName="${vft.topic.name}"> ${vft.topic.name}</a>
</td>
</tr>
</c:forEach>
</tbody>
</table>
</form>
function chooseTopic (obj) {
$("#topicId").val($(obj).attr("topicId"));
$("#topicName").val($(obj).attr("topicName"));
window.parent.$.fancybox.close();
}