日期:2014-05-17  浏览次数:21143 次

asp 父子页面传值
父页面中有一个不可编辑的文本框和一个按钮,点击按钮出来子页面,子页面是一个简单年历(日期上带有超连接),点了日期后其值传到父页面的文本框中

------解决方案--------------------
楼主不行就用session来处理吗。在子栏目得到时间后,放到session
session( "time ")=time
这样在父页面中调用它就行了
<input type= "text " value= " <%=session( "time ")%> ">
------解决方案--------------------
我现在也碰到这个类似的问题, 在父页中打开子页,子页的数据再传往父页,楼上说用session,好像不行耶,session不是要刷新吗,达不到楼主要的效果.
------解决方案--------------------
<!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> 父窗口 </title>
<script language= "javascript " type= "text/javascript ">
<!--
var win=null
//用于存储子窗口对象的全局变量

function output()
{
window.btn1.disabled=true;//禁用btn1,防止打开多个子窗口
var text=window.text1.value;//将要交互的值

//打开一无url的新窗口
win=window.open( ' ', 'newwin ', 'menubar=no,width=400,height=100,resizeable=no ');

//定义新窗口的document对象,以便对其写入代码
var childdoc=win.document;

childdoc.writeln( ' <html> ');
childdoc.writeln( ' <head> ');
childdoc.writeln( ' <title> 新开子窗口 </title> ');
childdoc.writeln( ' <script language= "javascript " type= "text/javascript "> function check_son(str){ alert(str) } </script> ')
//子窗口的测试函数

childdoc.writeln( ' </head> ');

childdoc.writeln( ' <body onunload= "window.opener.btn1.disabled=false "> ')
//关闭子窗口后父窗口的btn1恢复可用

childdoc.writeln( ' <input type= "text " name= "text2 " value= " '+text+ ' " /> ');
//接收父窗口传值

childdoc.writeln( ' <input type= "button " name= "Btn2 " value= "传回去 " onclick= "window.opener.text1.value=self.text2.value;window.opener.btn1.disabled=false;self.close() " /> ');
//将值传回到父窗口,父窗口的btn1恢复可用,关闭自身

childdoc.writeln( ' <input type= "button " name= "Btn3 " value= "关闭父窗口 " onclick= "window.opener.close() " /> ')
//关闭父窗口

childdoc.writeln( ' <input type= "button " name= "Btn3 " value= "刷新父窗口 " onclick= "window.opener.location.reload() " /> ')
//刷新父窗口

childdoc.writeln( ' <input type= "button " name= "Btn3 " value= "调用父窗口函数 " onclick= "window.opener.check_par(this.value) " /> ')
//调用父窗口函数

childdoc.writeln( ' </body> ');
childdoc.writeln( ' </html> ');

childdoc.close();
//关闭document对象

win.focus();
//子窗口取得焦点

}

function check_par(str)
{
alert(str);
}
-->
</script>
</head>

<body>
<input type= "button " name= "btn1 " value= "打开新窗口 " id= "btn1 " onclick= "output() "/>
<input name= "text1 " type= "text " id= "text1 " size= "10 " readonly= "true " value= "要传递的 "/>
<input type= "button " name= "btn2 " value= "关闭子窗口 " id