一:父頁面
1:校對人員編號文字框代碼:
[html] <input name="txtJDRY" type="text" id="txtJDRY" size="10" maxlength="40" readonly="readonly" value="${requestScope.txtGetYhbh }" class="ReadonlyText"/>
2:尋找編號按鈕代碼:
[html]
<input type="button" name="Button2" value="尋找編號" onClick="SearchCode()" accesskey="Q" style="cursor='hand'"/>
3:尋找編號按鈕所調用的js方法:SearchCode(),當點擊尋找編號按鈕之後彈出如片:
[html]
function SearchCode(){
var wndMEPImgPreView=window.open("<%=basePath%>cxaction.do?action=cxJDRY","wndMEPImgPreView","toolbar=no,location=no,menubar=no,scrollbars=yes,resizable=yes,width=800,height=600,left=200,top=200");
wndMEPImgPreView.focus();
}
二:子頁面
1:選中其中的一個選項按鈕,點擊添加編號按鈕會將選中的使用者編號傳到父頁面
其中這個頁面的js代碼如下:
button按鈕:
[html]
<input name="btnquery" type="button" id="btnquery" value=" 添加編號 " style="cursor='hand'" onclick="win()">
js win()方法:
[html]
function win(){
var radios = document.getElementsByTagName("input");
for(var i = 0 ;i<radios.length ; i++){
if(radios[i].type=="radio" && radios[i].checked){
window.opener.document.getElementById("txtJDRY").value=radios[i].value;//txtJDRY是要顯示在父頁面中那個文字框裡的文字框的id
}
}
window.close();
}
2:當點擊添加編號按鈕之後,會將你選中的單選框中的使用者編號傳入父頁面的文字框中 例如:選中編號為21,圖如下:
摘自 天易LoveZLL