js實現父頁面接收子頁面傳的值

來源:互聯網
上載者:User

一:父頁面

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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.