功能要求:在子页面设置一个按钮,点击后关闭子页面,传递数据到父页面。
实现如下:(以PHP代码为例)
父页面中有以下文本框:
<input name="gys" id="gys" style="width:150px" onClick="JavaScript:window.open('select _unit.php?form=form1&field=gys&field2=gys&span1=gys','','directorys=no,toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=800,height=300,top=300,left=500');" style="width:150px" placeholder="单击选择" >
子页面使用如下按钮:
echo "<td align='center'>";
echo "<input type='button' value='选择' onClick=\""."window.opener.document.getElementById('gys').value='".$row["username"]."';window.close();"."\">";
echo "</td>";
注意其中转义字符的使用"\""