JS——子視窗向父視窗傳值(radio選中的列值)
阿新 • • 發佈:2019-01-12
父視窗
<input type="text" class="font3" name="doctor_code" id="doctor_code">
<input type="text" class="font3" name="doctor_desc" id="doctor_desc">
<input type="button" class="button" value=".." name="doctor_help" onclick="_openDoctorWin()">
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); }
子視窗
<form name="docQueryForm" id="docQueryForm" method="post"> <table> <tr> <td align="center" valign="top"> <DataTable:table dataSrc="<%=doctorVOList%>" width="100%" align="center" isDisHead="true" nullMsg="MSG_3906" id="PrintA"> <DataTable:column head="" type="field" width="5" align="center"><!-- width="30" --> <Field:radio name="radio" value="$queryCode$"/> </DataTable:column> <DataTable:column head="DCT_190103" name="doctorCode" value="$doctorCode$" width="33%" align="left"> </DataTable:column> <DataTable:column head="DCT_190104" name="doctorName" value="$doctorName$" width="33%" align="left"> </DataTable:column> <DataTable:column head="DCT_190105" name="speciality" value="$speciality$" width="33%" align="left"> </DataTable:column> </DataTable:table> </td> </tr> </table> </from>
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(); }