日期:2014-05-17  浏览次数:21088 次

window.opener.document.form1.text0.value中如果使用变量?
window.opener.document.form1.text0.value=obj.value;
如果form1和text0均为变量要如何写?

此处是在做父窗口多个表单多个字段要从字窗口中选择数据时用
请教下面的代码要如何修改?
01.htm
<SCRIPT   LANGUAGE= "JavaScript ">  
<!--
function   openSubWindow(){  
window.open( "02.htm ", "mywin ",   "menubar=no,width=100,height=400,resizeable=yes ");  
}
//-->  
</SCRIPT>  
<BODY>  
<FORM   METHOD=POST   name=form1>  
<div   align= "center "> 表单1
<table   border= "1 "   width= "50% "   id= "table1 "   cellspacing= "0 "   cellpadding= "0 "   style= "border-collapse:   collapse ">
<tr> <td> 字段1: </td> <td> <INPUT   TYPE= "text "   NAME= "text0 "   onclick= "openSubWindow(); "> </td> </tr>
<tr> <td> 字段2: </td> <td> <INPUT   TYPE= "text "   NAME= "text1 "   onclick= "openSubWindow(); "> </td> </tr>
<tr> <td> 字段3: </td> <td> <INPUT   TYPE= "text "   NAME= "text2 "   onclick= "openSubWindow(); "> </td> </tr>
</table>
</div>
</FORM>
<FORM   METHOD=POST   name=form2>  
<div   align= "center "> 表单2
<table   border= "1 "   width= "50% "   id= "table1 "   cellspacing= "0 "   cellpadding= "0 "   style= "border-collapse:   collapse ">
<tr> <td> 字段1: </td> <td> <INPUT   TYPE= "text "   NAME= "text3 "   onclick= "openSubWindow(); "> </td> </tr>
<tr> <td> 字段2: </td> <td> <INPUT   TYPE= "text "   NAME= "text4 "   onclick= "openSubWindow(); "> </td> </tr>
<tr> <td> 字段3: </td> <td> <INPUT   TYPE= "text "   NAME= "text5 "   onclick= "openSubWindow(); "> </td> </tr>
</table>
</div>
</FORM>
02.htm
<SCRIPT   LANGUAGE= "JavaScript ">  
<!--
function   CloseSelf(){
obj   =   event.srcElement;
if(obj.tagName!= "INPUT ")   return;
window.opener.document.form1.text0.value=obj.value;
window.close();
}
//-->
</SCRIPT>
<BODY>
<FORM   METHOD=POST   name=abc>
<table   border= "1 "   width= "100% "   cellspacing= "0 "   cellpadding= "0 "   style= "border-collapse:   collapse ">
<tr> <td> <INPUT   TYPE= "text "   onclick= "CloseSelf(); "   NAME= "text "   value= "1111 "   size= "10 "> </td> </tr>
<tr> <td> <INPUT   TYPE= "text "   onclick= "CloseSelf(); "   NAME= "text "   value= "2222 "   size= "10 "> </td> </tr>
<tr> <td> <INPUT   TYPE= "text "   onclick= &quo