如何在窗口间进行数据传递

zhangx1818 2005-12-19 06:00:22
如何在窗口间进行数据传递,当在一个窗口内点击了一个文本框,然后弹出一个窗口,在弹出窗口内输入数据,最后把计算结果返回到文本框内
...全文
76 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
稽姬 2005-12-19
  • 打赏
  • 举报
回复
工作比较忙给你个大概的例子改改就行了。

<%@ page contentType="text/html;charset=gb2312"%>

<html>
<head>
<title>
测试页面一
</title>
<script language="javascript">
function openPage(id) {
var val=document.form1.text1.value;
openwin("../pagetransvalue/test2.jsp?value="+val, "test2",0,0,640,480);

}

function openwin(URL,winName,leftMargin,topMargin,winWidth,winHeight){

window.open(URL,winName,"left="+leftMargin+" top="+topMargin+" width="+winWidth+", height="+winHeight+" menu=yes status=yes resizable=no scrollbars=yes");
}
</script>
</head>
<body bgcolor="#606060">
<form name="form1" method="post">
<table align="center" border="4" cellpadding="0" cellspacing="0" width="60%">
<tr>
<th colspan="2" style="text-align:center;font-family:隶书;font-weight:bold;color:#990000;">测试页面一</th>
</tr>
<tr>
<td width="60%" align="center">
<input name="text1" size="36">
</td>
<td width="40%" align="center">
<a href="javascript:openPage(this);">LinkPage</a>
</td>
</tr>
</table>
</form>
</body>
</html>


<%@ page contentType="text/html;charset=gb2312"%>
<html>
<head>
<title>
测试页面二
</title>
<script>
function returnValue() {
window.opener.document.form1.text1.value = document.form2.text2.value;
window.close();
return;
}
</script>
</head>
<body bgcolor="#606060">
<form name="form2" method="post">
<table align="center" border="4" cellpadding="0" cellspacing="0" width="60%">
<tr>
<th colspan="2" style="text-align:center;font-family:隶书;font-weight:bold;color:#990000;">测试页面二</th>
</tr>
<tr>
<td width="60%" align="center">
<%
String str=request.getParameter("value");
str= new String(str.getBytes("ISO-8859-1"),"GB2312");
%>
<input name="text2" size="36" value="<%=str%>" hidefocus>
</td>
<td width="40%" align="center">
<input type="button" name="button" value="将结果返回" onclick="returnValue();">
</td>
</tr>
</table>
</form>
</body>
</html>
weinickli 2005-12-19
  • 打赏
  • 举报
回复
window.opener.inputtext.value=inputtext.value

62,630

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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