如何取得window.open打开窗口的返回值?

aomin1981 2007-07-21 05:55:36
A文件如下:
<select name="brand" onchange="window.open('clxz.asp?brand='+this.value,'','');">
<option>==请选择==</option>
</select>
车类选择:
<input name="kind" type="text" id="kind" size="10" maxlength="20">
产地:
<input type="text" name="textfield">

B文件如下:
<!--#include file="../conn.asp"-->
<!--#include file="../inc/function.asp"-->
<html>
<head>
<title>新车信息输入</title>
</head>
<body>
<%
brand=Request.QueryString("brand")
set rs=server.createobject("adodb.recordset")
rs.open"select * from Abrand where brand='"& brand &"'",conn,1,1
%>
<form action="" method="get">
<input name="kind" type="text" id="kind" value="<%=rs("kind")%>"/>
<label>
<input name="kind2" type="text" id="kind2" value="<%=rs("kind")%>"/>
<input type="submit" name="Submit" value="提交">
</label>
</form>
<%
rs.close
%>
</body>
</html>

请问我应该如何做才能让B文件的两个文本域中的值返回到A文件的两个文本域中?谢谢。
...全文
1825 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
aomin1981 2007-07-22
  • 打赏
  • 举报
回复
自已顶一下。
aomin1981 2007-07-22
  • 打赏
  • 举报
回复
a.asp

<select name="brand" onchange="window.open('b.asp?brand='+this.value,'','');">
<option>==请选择==</option>
</select>
车类选择:
<input name="kind" type="text" id="kind" size="10" maxlength="20">
产地:
<input name="producing" type="text" id="producing" size="10">


*************************************************************************

b.asp

<!--#include file="../conn.asp"-->
<!--#include file="../inc/function.asp"-->
<html>
<head>
<title></title>
</head>
<body>
<%
brand=Request.QueryString("brand")
set rs=server.createobject("adodb.recordset")
rs.open"select * from Abrand where brand='"& brand &"'",conn,1,1
%>
<script language="JavaScript">
opener.document.forms[0].kind.value='<%=rs("kind")%>';
opener.document.forms[0].producing.value='<%=rs("producing")%>';
</script>
<%
rs.close
%>
<script language="JavaScript">
self.close()
</script>
</body>
</html>


我是这样做的。
kindwell 2007-07-22
  • 打赏
  • 举报
回复
你要是多试试也许就会明白了,
比如说的第一种方法,先在A文件中用
<form name="form1"></form>把那两个text包起来,
然后在B文件中把那个submit按钮换成普通的按钮,加上
onclick事件,在调用的方法里面加上
window.opener.document.form1.kind.value = refVal;
其中refVal是"<%=rs("kind")%>"这个值作为参数传过来的。

大致的代码是
<!--input type="submit" name="Submit" value="提交"-->
<input type="button" name="submit" value="提交" onclick="doSubmit('<%=rs("kind")%>')">

js里的代码是
function doSubmit(refVal) {
.......
window.opener.document.form1.kind.value = refVal;
.......
}


window.opener指的是打开子窗口的父窗口。
aomin1981 2007-07-22
  • 打赏
  • 举报
回复
再顶
aomin1981 2007-07-21
  • 打赏
  • 举报
回复
还是不太懂,能说详细点吗?
kindwell 2007-07-21
  • 打赏
  • 举报
回复
可以用类似于
window.opener.document.FORM1.TEXT1.value = "ABCDEFG";
之类的语句赋值,当然需要在A文件中指定form的name。
也可以在B文件中给window.returnValue赋值(比如用逗号分割的字符串),
A文件中用var returnVal = window.open('clxz.asp?brand='+this.value,'','');
来取得这个returnValue,然后用split从字符串取得数组后赋值。

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧