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

子窗口传值给父窗口的问题(再开一贴)
父窗口   用window.open   打开子窗口
子窗口
<form   name= "form1 "..>
<input   type= "radio "   value= "1 ".....>
<input   type= "radio "   value= "2 ".....>
<input   type= "submit ">
</form>
中的值传到父窗口的 <input   type= "text "....> 中如何实现?

请写具体点

------解决方案--------------------
父窗口 用window.open 打开子窗口
<form method=post action= " " name= "fm1 " id= "fm1 ">
<input type= "text " name= "test " value= " ">
</form>
子窗口
<script language= "JavaScript ">
<!--
function returnVal()
{
var val1=document.getElementById( "radio1 ").value;
window.opener.fm1.test.value=val1;
}

//-->
</script>
<form name= "form1 "..>
<input type= "input " value= "1 " id= "radio1 ">
<input type= "button " onclick= "returnVal() " >
</form>

------解决方案--------------------
假设你的父窗口中的text元素名为text1,那么在子窗口中加上如下代码
javascript:parent.document.all( 'form1 ').text1.value=要传的值
------解决方案--------------------
得到的值却都是1 这是什么问题啊! 因为radio1的值就是1,就算有多个radio1,用getElementById也会只取到第一个.
------解决方案--------------------
<input type= "input " value= "1 " onclick= "window.opener.fm1.test.value=this.value ">