JS——子窗口向父窗口传值(radio选中的列值)

父窗口



    function _openDoctorWin(){
        var doctor_code = document.getElementById("doctor_code");
        var doctor_desc = document.getElementById("doctor_desc");
        
        var height = window.screen.height;
        var width = parseInt(window.screen.width / 2);
        var url = "<%=Env.URL_PREFIX%>/clm/showDoctorCode.do?type=show";
        var nw = window.open(url,"_new","scrollbars=yes,resizable=yes,left="+width+",top=0,width="+width+",height="+height);
    }

子窗口

    function submit_onclick() {
        var table = document.getElementById("PrintA");
        var len = table.rows.length;
        var code = opener.document.getElementsByName("doctor_code");
        var desc = opener.document.getElementsByName("doctor_desc");

        if (len != 2) {
            for (var i = 0; i < document.docQueryForm.radio.length; i++) {
                if (document.docQueryForm.radio[i].checked == true) {
                    /*rows是行cells是列*/
                    code[0].value = table.rows[i + 1].cells[1].innerHTML;
                    desc[0].value = table.rows[i + 1].cells[2].innerHTML;
                    break;
                }
            }
        } else {
            if (document.docQueryForm.radio.checked) {
                /*rows是行cells是列*/
                code[0].value = table.rows[1].cells[1].innerHTML;
                desc[0].value = table.rows[1].cells[2].innerHTML;
            }
        }

        code[0].focus();
        code[0].blur();
        window.close();
    }

 

你可能感兴趣的:(JavaScript)