如何利用脚本传值

css12345 2005-11-03 10:45:52
现在有两个页面分别为a.html和b.html,问题描述,在a.html页面上有两个文本框和一个按钮。在b.html页面上也是有两个文本框和一个按钮
现在点个超连接来到b.html页面,然后在b.html页面的两个文本框上,分别输入值,然后点个按钮,关闭该窗口(b.html),同时把在b.thml
页面上输入的值,给传给a.html页面的文本框上,请问在b.html页面上的这个按钮的的事件方法该如何编写。特急,分不够再加。。
...全文
131 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
css12345 2005-11-03
  • 打赏
  • 举报
回复
谢谢楼上的朋友,真是高人呢。。
fantiny 2005-11-03
  • 打赏
  • 举报
回复
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<SCRIPT LANGUAGE="JavaScript">
<!--
function setValue(){
document.Form1.txt1.value= "changed" ;
newoption = new Option("changed","changed");
document.Form1.sel1.add(newoption);
}

function openWin(){

objWin = window.open('','');
objWin.document.open();
objWin.document.write ("<body bgcolor=#cccccc></body>");
objWin.document.write ("<input type='button' value='SetValue' onclick='opener.setValue();window.opener=null;window.close()'>");
objWin.document.write ("<input type='button' value='CloseMe' onclick='if(opener.closed){window.opener=null;window.close()}'>");
objWin.document.close;
}
//-->
</SCRIPT>
</HEAD>

<BODY>
<FORM name="Form1" METHOD=POST ACTION="">
<INPUT TYPE="text" NAME="txt1" value="default">
<INPUT TYPE="button" NAME="abc" onclick="openWin()" value="openWin">
<select name="sel1"></select>
</FORM>
</BODY>
梅雪香 2005-11-03
  • 打赏
  • 举报
回复
b.htm


<script>
function guanbi(){
window.opener.form2.aa.value = document.form1.aa.value;


alert(window.opener.form2.aa.value);
window.opener=null;
window.close();
}
</script>
<body>
<form name="form1"action="" method="get">
<input name="aa" type="text">
<input name="a" type="button" value="closed" onClick="guanbi()">
</form>
</body>
css12345 2005-11-03
  • 打赏
  • 举报
回复
哪个朋友能帮我修改下上边的脚本啊。我都搞糊涂了。。
moodboy1982 2005-11-03
  • 打赏
  • 举报
回复
先关注,等下再来回答吧。
css12345 2005-11-03
  • 打赏
  • 举报
回复
我的a.html
<script>
function open2(){
window.open("b.htm","ceshi","height=350,width=350");
}
</script>
<body>
<form name="form2"action="" method="get">
<input name="aa" type="text">
<input name="a" type="button" value="open2" onClick="open2()">
</form>
</body>

b.html

<script>
function guanbi(){
window.opener.form.ProductImage.value = document.form1.aa.value;


alert(document.form1.aa.value);
window.close();
}
</script>
<body>
<form name="form1"action="" method="get">
<input name="aa" type="text">
<input name="a" type="button" value="closed" onClick="guanbi()">
</form>
</body>

请哪个高人帮我看下哪里错了。
danis_cn 2005-11-03
  • 打赏
  • 举报
回复
a.htm

onclick="window.open('b.htm','')"
文本框ProductImage


B.htm

window.opener.form.ProductImage.value='<%=filename%>';
css12345 2005-11-03
  • 打赏
  • 举报
回复
能简单贴个原码吗?求求楼上的朋友了。
surfchen 2005-11-03
  • 打赏
  • 举报
回复
在a.html用window.open打开b.html

b可得到opener对象,这个opener就是指到a.html的window对象
css12345 2005-11-03
  • 打赏
  • 举报
回复
自己顶下,,特急。。请路过的高人指点。

87,902

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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