如何在窗口间进行数据传递,当在一个窗口内点击了一个文本框,然后弹出一个窗口,在弹出窗口内输入数据,最后把计算结果返回到文本框内

解决方案 »

  1.   

    window.opener.inputtext.value=inputtext.value
      

  2.   

    工作比较忙给你个大概的例子改改就行了。<%@ 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>