新开窗口后根据复选框的选择结果动态在父页面创建文本框
a.html
HTML code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title></title>
</head>
<body>
<div id="showinput">
此处动态显示文本框
</div>
<input type="button" onclick="window.open('b.html','newwindow','height=100,width=400,top=0,left=0,toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no');" value="选择" />
</body>
</html>
b.html
HTML code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title></title>
</head>
<body>
<form method="post" name="form1">
<input type="checkbox" name="test" value="1" />选项一
<input type="checkbox" name="test" value="2" />选项二
<input type="checkbox" name="test" value="3" />选项三
<input type="button" value="确定" />
</form>
</body>
</html>
新开窗口后根据复选框的选择结果动态在父页面创建文本框。
------解决方案--------------------楼主试试 window.opener
------解决方案--------------------
b.html的代码改为
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title></title>
<script>
function checks()
{
var chks=document.getElementsByName("test");
var val1="";val2="";
var count=0;
for(var i=0;i<3;i++)
{
for(var j=0;j<3;j++)
{
if(i==j || count>0)
{
continue;
}
if(chks[i].checked && chks[j].checked)
{
if(count==0)
{
val1=chks[i].value;
val2=chks[j].value;
count++;
break;
}
else
{
count++;
}
}
}
}
if(count!=1)
{
alert("必须勾选两个复选框!已勾选"+count+"");
return false;
}
var o_div=window.opener.document.getElementById("showinput");
o_div.innerHTML="<input type=text value='"+val1+"'><input type=text value='"+val2+"'>";
}
</script>
</head>
<body>
<form method="post" name="form1">
<input type="checkbox" name="test" value="1" />选项一
<input type="checkbox" name="test" value="2" />选项二
<input type="checkbox" name="test" value="3" />选项三
<input type="button" value="确定" onclick='checks()'/>
</form>
</body>
</html>