点击链接,弹出一个窗口,窗口里面设置表单,输入数据点确定,又把数据显示在原页面上,这个怎么实现?
------解决方案--------------------
用javascript写个例子
<script LANGUAGE="JavaScript">
function return_value()
{
if(opener){
var s = "";
var a = document.getElementsByName("selValue");
for(var i=0; i<a.length; i++)
{
if (a[i].checked)
{
s = s + a[i].value + ",";
}
}
var src=new Array(5);
for(var i=0; i<5; i++) {
src[i]=s.substring(0,s.indexOf(","));
s=s.substring((s.indexOf(",")+1),s.length);
}
opener.document.form1.ygxxbh.value=src[0];
opener.document.form1.xm.value=src[1];
opener.document.form1.ygjb.value=src[2];
}
window.self.close()
}
</script>
------解决方案--------------------
你在弹出的页面加上
<base target='_self'>
就OK了
------解决方案--------------------
一个简单的例子:不用JSP只用到一点javascript的opener,也不用刷新父页面
test.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>parent</title>
<script type="text/JavaScript">
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
//-->
</script>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
子页面传来的值:
<input name="test" type="text" id="test" disabled/>
<input name="Submit" type="button" onclick="MM_openBrWindow('openW.html','','location=yes,status=yes,resizable=yes,width=400,height=400')" value="打开子页面" />
</form>
</body>
</html>
openW.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>test</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
要传给父页面的值:
<input type="text" name="test2" />
<input type="button" name="Submit" value="传出" onclick="javascript:opener.form1.test.value=this.form.test2.value" />
</form>
</body>
</html>