2005/06/14 | 利用javascript怎么接收从另外一个页面的表单传递过来的数值?
类别(WEB相关) | 评论(0) | 阅读(363) | 发表于 13:33
先打开form1
再打开form2,按里面的显示数据的按钮
form1.html
-------------
<head>
<script language="javascript">
<!--
function opennew()
{
window.open("form2.html","music","height=250, width=280, top=0, left=0, toolbar=no, menubar=no, scrollbars=no,resizable=yes,location=no, status=no")
}
-->
</script>

</head>
<form name=form1 action="" method="" id=lin>
form1的值:<br>姓名:<input type=text name=text1 id=xing><Br>
爱好:<input type="text" name=text11><br>
性别:<input type="text" name=text12><br>
好处:<input type="text" name=text3>
<input type=button value="浏览确认" onclick="opennew()">
</form>
------------------
form2.html
-----------
<html>
<head>
<title>Hi</title>
<script language=javascript>
<!--
function xing1(){
window.opener.document.form1.text11.value=form2.txt2.value;
window.close();
}
-->
</script>
<script language="javascript" type="text/javascript">
function xing(){    
var dd=window.opener.location.href; //父窗口的地址
     var aa=window.opener.form1.text1.value;
        var bb=window.opener.form1.text11.value;
var cc=window.opener.form1.text12.value;
                     document.form2.txt2.value=aa;    
                        document.form2.txt22.value=bb;
document.form2.txt3.value=cc;
document.form2.txt4.value=window.opener.form1.text3.value;
document.form2.txt5.value=dd;
                }
    </script>
</head>
<body>
<form action="form.asp" method="post" name="form2" target=_blank>
form2的值:<br>姓名:<input type="text" name="txt2" readonly/>
<br>爱好:<input type="text" name="txt22" readonly><br>
性别:<input type="text" name="txt3"><br>
好处:<input type="text" name="txt4"><br>
父地址:<input type="text" name="txt5" size=35><br>
<input type="submit" name=submit value="提交">
        </form>
<input type=button name=button value="关闭窗口" onclick="xing1()">
<input type=button name=button1 value="显示数据" onclick="xing()">
</body>
</html>
0

评论Comments