关于showModalDialog的简单问题,如何在弹出的窗口中,把选择的一条记录填充到父窗口里,希望高手进来,小弟感激不尽!!

pb2006 2005-05-15 12:33:03
父窗口:store.asp
子窗口:help.asp
store.asp代码
<script language="javascript">
function f_help()
{
code=document.frm.receman.value;
window.showModalDialog("help.asp?code="+code," ");
}
</script>
<form name=frm>
<select size="1" name="receman">
<% call selectstr("shr","0")%>
</select>
<input name="shr" type=button value=? onclick="f_help()">
<input name="tel" type="text"> '将模式窗口中的tel变量填充到此栏位
<input name="fax" type="text"> '将模式窗口中的fax变量填充到此栏位
<input name="address" type="text"> '将模式窗口中的address变量填充到此栏位
</form>

help.asp 代码
<script language="javascript">
function deli(id)
{
document.frm1.shrdetail.value=(id);
}
</script>

<form name="frm1" method="post">
<input name=shrdetail type="hidden">
</head>
<table >
<% ShowContent%>
</table>
<input type="button" value=确定>
</form>
<%
sub ShowContent()
response.write "<tr class=tr1> "
response.write "<th width='1%' > </th>"
response.write "<th width='7%'>地址</th>"
response.write "<th width='4%'>电话</th>"
response.write "<th width='4%'>传真</th>"
if not rs.eof then
do while not rs.eof
response.write "<tr > "
response.write "<td ><input type=radio value="&rs("addr")&","&rs("tel")&","&rs("fax")&" onclick='deli(this.value)'></td>" 选择一条记录后,把这三个变量传到一个hidden表单中
response.write "<td >"&rs("addr")&"</td>"
response.write "<td >"&rs("tel")&"</td>"
response.write "<td >"&rs("fax")&"</td>"
response.write "</tr>"
rs.MoveNext
loop
end if
end sub
%>
我的问题是:假如在弹出的窗口中,我选择了一条记录,当我点确定按钮后,如何把这条记录(电话、地址、传真)自动填充到父窗口的电话、地址、传真三个栏位呢??
...全文
202 22 打赏 收藏 转发到动态 举报
写回复
用AI写文章
22 条回复
切换为时间正序
请发表友善的回复…
发表回复
pb2006 2005-05-16
  • 打赏
  • 举报
回复
up
chocobo_1982 2005-05-15
  • 打赏
  • 举报
回复
在弹出的窗口加个事件
function abc() {
window.returnValue = 需要返回值;
window.close();
}

<input type=button onclick="abc()">

不知道你是不是这意思
iuhxq 2005-05-15
  • 打赏
  • 举报
回复
为什么告诉我sData.document.frm为空,或不是对象


把document去掉呀
改为:sData.frm
pb2006 2005-05-15
  • 打赏
  • 举报
回复
先谢谢楼上大哥的,我自己想出一个办法,可为什么不行呢
我在子窗口里这样写
function setinfo()
{
sData= window.dialogArguments;
var info=document.frm.shrdetail.value;
var arrinfo=info.split(",");
sData.document.frm.deliaddr.value =arrinfo[1];
sData.document.frm.tel.value =arrinfo[2];
sData.document.frm.fax.value =arrinfo[3];
window.close;
}
</script>

<input type="button" value=确定 onclick="setinfo()">
为什么告诉我sData.document.frm为空,或不是对象
sc3wood 2005-05-15
  • 打赏
  • 举报
回复
关注。
iuhxq 2005-05-15
  • 打赏
  • 举报
回复
<form name="form1" method=post action="">
<input type="text" name="username"><input type="button" onclick="window.showModalDialog('test.html',window);">
</form>


<input type="text" name="username"><input type="button" onclick="window.dialogArguments.form1.username.value=username.value;window.close();">
pb2006 2005-05-15
  • 打赏
  • 举报
回复
up
pb2006 2005-05-15
  • 打赏
  • 举报
回复
先谢谢楼上大哥的,我自己想出一个办法,可为什么不行呢
我在子窗口里这样写
function setinfo()
{
sData= window.dialogArguments;
var info=document.frm.shrdetail.value;
var arrinfo=info.split(",");
sData.document.frm.deliaddr.value =arrinfo[1];
sData.document.frm.tel.value =arrinfo[2];
sData.document.frm.fax.value =arrinfo[3];
window.close;
}
</script>

<input type="button" value=确定 onclick="setinfo()">
为什么告诉我sData.document.frm为空,或不是对象
iuhxq 2005-05-15
  • 打赏
  • 举报
回复
index.html
<form method=post action="">
<input type="text" name="username"><input type="button" onclick="username.value=window.showModalDialog('test.html');">
</form>

test.html
<input type="text" name="username"><input type="button" onclick="window.returnValue=username.value;window.close();">


上面两个文件试试
孟子E章 2005-05-15
  • 打赏
  • 举报
回复
http://dev.csdn.net/develop/article/15/15113.shtm
yjbnew 2005-05-15
  • 打赏
  • 举报
回复
chocobo_1982() 说的对!
sc3wood 2005-05-15
  • 打赏
  • 举报
回复
关注
chocobo_1982 2005-05-15
  • 打赏
  • 举报
回复
好象不是的吧
sData= window.dialogArguments;
你这里的 sData是获得父窗口窗口传过来的值,并不是父窗口

你可以定义一个 数组,先把所有需要提交到模块的值全部放在一个数组里,然后再通过模块窗口来获得

sData.document.frm 好象没这样写法的哦~~~
thinkming 2005-05-15
  • 打赏
  • 举报
回复
http://www.webdiyer.com/utility/procgen.aspx去去这个网址吧,有和你相似的源码
pb2006 2005-05-15
  • 打赏
  • 举报
回复
up
pb2006 2005-05-15
  • 打赏
  • 举报
回复
先谢谢楼上大哥的,我自己想出一个办法,可为什么不行呢
我在子窗口里这样写
function setinfo()
{
sData= window.dialogArguments;
var info=document.frm.shrdetail.value;
var arrinfo=info.split(",");
sData.document.frm.deliaddr.value =arrinfo[1];
sData.document.frm.tel.value =arrinfo[2];
sData.document.frm.fax.value =arrinfo[3];
window.close;
}
</script>

<input type="button" value=确定 onclick="setinfo()">
为什么告诉我sData.document.frm为空,或不是对象
chocobo_1982 2005-05-15
  • 打赏
  • 举报
回复
store.asp代码
<script language="javascript">
function f_help()
{
code=document.frm.receman.value;

var AAA;
//这里就是定义接收返回值,AAA
AAA= window.showModalDialog("help.asp?code="+code," ");
}
</script>
。。。。。




help.asp 代码
<script language="javascript">

function abc() {
window.returnValue =document.all["thisbutton"].text;
}

</script>
<html>
<input name="thisbutton" text="bb" onclick=abc()>
</html>

试试先
chocobo_1982 2005-05-15
  • 打赏
  • 举报
回复
老简单的呀,定义一个数组,然后,按了个button后,触发事件,
分别把你选的记录的3个值传给这个数组,然后把这个数组返回回去,

就是window.returnValue = 需要返回值;

然后window.close();
pb2006 2005-05-15
  • 打赏
  • 举报
回复
大哥,能不能按照我的思路帮我写详细点呢??我以前没用过模式窗口,对这个窗口的用法不太熟悉
window.returnValue = 需要返回值;这个返回值怎么写呢???
在父窗口里怎么接收呢?接收到后,怎么把三个input填充上返回的值呢?????
pb2006 2005-05-15
  • 打赏
  • 举报
回复
当我选择某一条记录后,即选择一个radio,然后把这条记录的三个变量赋值给radio的value
三个值用逗号分割开,我怎么做才能把这三个变量填充到父窗口中呢

28,391

社区成员

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

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