如何利用js将多个值从子页传到父页? 用window.returnValue,每个页面都有。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 To: wcqgm(傲翔白鸽) 我用的就是用window.returnValue,但值传不过去,老出错。 an_array_c[0]=window.document.frm.a1.Value;是不是这行提示错,还是那一行呀如果是这行的话加一个this.window.document.frm.al.Value看看有没有什么反应 To: 52juanjuan(Fibona)加 this 也不行。提示缺少函数。 第一、在t2页面,window.returnValue = an_array_c; 而不是an_array_c(4);第二、在t2中应该能够接收t1的参数,因此,在t1页面应该新增一个数组:var an_array_to = new Array("","","","");在赋值后将showModalDialog的第二个参数设置为an_array_to在t2页面通过 var an_array_to = window.dialogArguments获取 搞了半天还未搞明白。t1的我已改为:<script language='javascript'> function shows(){ var a = window.showModalDialog("t2.php","a","dialogHeight: 300px; dialogWidth: 200px; dialogTop: 200px; dialogLeft: 300px; center: no; help: no; resizable:no; status:no"); window.document.pfrm.T1.value=a[0] window.document.pfrm.T2.value=a[1] window.document.pfrm.T3.value=a[2] window.document.pfrm.T4.value=a[3]}</script>T2的改为:<script language='javascript'> function okClick(){ var a=new Array("","","","") a[0]=window.document.frm.a1.Value a[1]=window.document.frm.a2.Value a[2]=window.document.frm.a3.Value a[3]=window.document.frm.a4.Value window.returnValue = a window.close()}</script>关闭T2时,T1的各Text中的值均为:undefined;但如果将T2中的script更改为:function okClick(){ var a=new Array("aa","bb","cc","dd") window.returnValue = a window.close()}</script>则可得到正确的值。错在哪儿了? 本机测试通过:t1.htm----------------------------------------------------------------------------------<html><head><meta http-equiv="Content-Language" content="zh-cn"><meta http-equiv="Content-Type" content="text/html; charset=??????"><script language='javascript'> //var an_array = new Array("abcde","abcdef","abcdefg","abcdefgh"); function shows() { an_array = window.showModalDialog("t2.htm","Dialog","dialogHeight: 300px; dialogWidth: 200px; dialogTop: 200px; dialogLeft: 300px; center: no; help: no; resizable:no; status:no"); pfrm.T1.value=an_array[0]; pfrm.T2.value=an_array[1]; pfrm.T3.value=an_array[2]; pfrm.T4.value=an_array[3]; }</script><title>Page 1</title></head><body><form method="POST" name="pfrm" action="aaa.php"> <input type="text" name="T1" size="20" value=""></p> <input type="text" name="T2" size="20" value=""></p> <input type="text" name="T3" size="20" value=""></p> <input type="text" name="T4" size="20" value=""></p><input type="button" value="Add" onClick="shows()" class="bt"> <p><input type="submit" value="提交" name="B1"></p> <input type="reset" value="重置" name="B2"></p></form></body></html>t2.htm----------------------------------------------------------------------------------<html><head><meta http-equiv="Content-Language" content="zh-cn"><meta http-equiv="Content-Type" content="text/html; charset=??????"><script language='javascript'> function okClick() { var an_array_c = new Array(); an_array_c[0]=frm.a1.value; an_array_c[1]=frm.a2.value; an_array_c[2]=frm.a3.value; an_array_c[3]=frm.a4.value; window.returnValue = an_array_c; window.close(); }</script><title>Page 2</title></head><body><form name="frm"> <input type="text" name="a1" size="20" Value="aa"></p> <input type="text" name="a2" size="20" Value="bb"></p> <input type="text" name="a3" size="20" Value="cc"></p> <input type="text" name="a4" size="20" Value="dd"></p><input type="button" value="?" onClick="okClick()" class="bt"></form></body></html> 多谢 stefli((桂电)):但为何不用加“window.document”。 JQuery的scroll和draggable问题 有关IE9下的window.status的问题 setCapture(), addEventListener()问题 如何反编这种格式js help 关于Select框选项的问题,高手请进,急,在线等待 火狐浏览器onclick="submit();"提交不了 require()用法求助 高分求三级连动下拉框的代码! 有人能解决这个不能提交的表单吗? 我在800*600下用层写了个下拉菜单,并把层定位了,可是在1024*768下浏览时,下拉菜单的位置就不是我想要的位置了,如果取得相对位置啊! 如何把文本框的值取过来传到下一页?(在线等)
提示缺少函数。
第二、在t2中应该能够接收t1的参数,因此,在t1页面应该新增一个数组:
var an_array_to = new Array("","","","");
在赋值后将showModalDialog的第二个参数设置为an_array_to
在t2页面通过 var an_array_to = window.dialogArguments获取
t1的我已改为:
<script language='javascript'>
function shows()
{
var a = window.showModalDialog("t2.php","a","dialogHeight: 300px; dialogWidth: 200px; dialogTop: 200px; dialogLeft: 300px; center: no; help: no; resizable:no; status:no");
window.document.pfrm.T1.value=a[0]
window.document.pfrm.T2.value=a[1]
window.document.pfrm.T3.value=a[2]
window.document.pfrm.T4.value=a[3]
}
</script>T2的改为:
<script language='javascript'>
function okClick()
{
var a=new Array("","","","")
a[0]=window.document.frm.a1.Value
a[1]=window.document.frm.a2.Value
a[2]=window.document.frm.a3.Value
a[3]=window.document.frm.a4.Value
window.returnValue = a
window.close()
}
</script>关闭T2时,T1的各Text中的值均为:undefined;
但如果将T2中的script更改为:
function okClick()
{
var a=new Array("aa","bb","cc","dd")
window.returnValue = a
window.close()
}
</script>
则可得到正确的值。
错在哪儿了?
t1.htm
----------------------------------------------------------------------------------
<html>
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=??????">
<script language='javascript'>
//var an_array = new Array("abcde","abcdef","abcdefg","abcdefgh");
function shows()
{
an_array = window.showModalDialog("t2.htm","Dialog","dialogHeight: 300px; dialogWidth: 200px; dialogTop: 200px; dialogLeft: 300px; center: no; help: no; resizable:no; status:no");
pfrm.T1.value=an_array[0];
pfrm.T2.value=an_array[1];
pfrm.T3.value=an_array[2];
pfrm.T4.value=an_array[3];
}
</script>
<title>Page 1</title>
</head><body><form method="POST" name="pfrm" action="aaa.php">
<input type="text" name="T1" size="20" value=""></p>
<input type="text" name="T2" size="20" value=""></p>
<input type="text" name="T3" size="20" value=""></p>
<input type="text" name="T4" size="20" value=""></p><input type="button" value="Add" onClick="shows()" class="bt">
<p><input type="submit" value="提交" name="B1"></p>
<input type="reset" value="重置" name="B2"></p>
</form></body>
</html>t2.htm
----------------------------------------------------------------------------------
<html>
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=??????">
<script language='javascript'>
function okClick()
{
var an_array_c = new Array();
an_array_c[0]=frm.a1.value;
an_array_c[1]=frm.a2.value;
an_array_c[2]=frm.a3.value;
an_array_c[3]=frm.a4.value;
window.returnValue = an_array_c;
window.close();
}
</script>
<title>Page 2</title>
</head><body><form name="frm">
<input type="text" name="a1" size="20" Value="aa"></p>
<input type="text" name="a2" size="20" Value="bb"></p>
<input type="text" name="a3" size="20" Value="cc"></p>
<input type="text" name="a4" size="20" Value="dd"></p><input type="button" value="?" onClick="okClick()" class="bt">
</form></body></html>