日期:2014-05-16  浏览次数:20370 次

怎么从一个jsp 页面 取值 赋给另一个jsp 页面的一个text 控件
在my.jsp   有一个burron   上   onclick()事件上调用如下的代码
document.open( 'applyExpend.do?method=choiceRZY ', 'newwindow ', 'height=400,width=300,top=200,left=400,toolbar=no,menubar=no,scrollbars=yes,   resizable=no,location=no,   status=no ');  

进入action     后从sql中取值显示在上面用jp新开的窗口上,然后给用户选择,

我怎么从jp新开的那个窗体上把值在赋给my.jsp呢??????


------解决方案--------------------
window.parent.opener.myform.result.value= "滴吧贱B "

myform 是父窗体的form名称 result是父窗体form中的一个元素
------解决方案--------------------
我以前写过几个页面间传值的小例子,找给比较简单的给你吧,把代码直接粘出来就ok了:
---------------------------------
这是父页面:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns= "http://www.w3.org/1999/xhtml ">
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 " />
<title> AA </title>
</head>
<body>
<form name= "form ">
向子页面传的值:
<input type= "text " name= "aa " /> <input type= "button " value= "submit " onclick= "window.open( 'b.html ', '_blank ', 'height=200,width=400,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no '); " />
</form>
</body>
</html>
---------------------------------
这是弹出页面:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns= "http://www.w3.org/1999/xhtml ">
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 " />
<title> BB </title>
<script language= "javascript "> <!--
function fuzhi(){
var a = document.ad.str1.value;
var b = document.ad.str2.value;

var c = a + b;

window.opener.form.aa.value = c;
window.close();


}


// -->
</script>
</head>

<body>
<form name= "ad ">
<table width= "300 " height= "150 " border= "0 " align= "center " cellpadding= "0 " cellspacing= "2 " bgcolor= "#FF0000 ">
<tr>
<td bgcolor=white> 父窗口传来的值是:
<!-- ----------------------------- -->
<script language= "javascript ">
var aaa=window.opener.form.aa.value;
document.write(aaa);
</script>
<!-- ----------------------------- -->
</td>
</tr>
<tr>
<td align= "center " valign= "middle " bgcolor= "#FFFFFF ">
<input type= "button " value= "给母窗口赋值 " onclick= "fuzhi() " />
</td>
</tr>
<td bgcolor=white>
回传的第一个字符串: <br> <input type= "text " name= "str1 " /> <br> 回传的第二个字符串: <br> <input type= "text " name= "str2 " />
</td>
</table>
</form>
</body>
</html>