window.opener.form1.text1.value=form2.text2.value
.....

解决方案 »

  1.   

    1.htm
    <form name="form1" method="post" action="">
      <input type="text" name="txt">
      <input type="submit" name="Submit" value="Submit" onclick="window.open('2.asp')">
    </form>
    2.htm
    <script language="JavaScript" type="text/JavaScript">
    window.opener.form1.txt.value="ok"
    window.close()
    </script>
      

  2.   

    给你一个好理解点的例子,希望能对你有所帮助第一个文件:main.htm
    <!--author:zangleo filename:main.htm-->
    <html>
    <head>
    <title>JavaScript示例</title>
    </head>
    <script language="javascript">
    function openOtherPage(){
    window.open("sub.htm");
    }
    </script>
    <body>
    <input type="text" id="txtMain" value="">
    <input type="button" value="打开子页面" onclick="openOtherPage()">
    </body>
    </html>第二个文件 sub.htm
    <!--author:zangleo filename:sub.htm-->
    <html>
    <head>
    <title>JavaScript示例</title>
    </head>
    <script language="javascript">
    function returnValue(){
    window.opener.txtMain.value=txtSub.value;
    }
    </script>
    <body>
    <input type="text" id="txtSub" width="200" value="Input a value">
    <input type="button" value="返回值" onclick="returnValue()">
    </body>
    </html>
      

  3.   

    但是当副页面是公用是呢??
    例如副页面是用来设置一些属性时!!!
    无法在副页面确定主页面中input的name??
      

  4.   

    window.opener;返回打开本窗口的窗口对象你把window.opener这个弄清楚就行了~
      

  5.   

    静态页面的值传递(三部曲).      wanghr100 [原作] 
    http://dev.csdn.net/develop/article/29/29975.shtm
      

  6.   

    因为偶对js从没怎么编写过,以前都是直接拿来用的,所以很多细节真不懂呵!
    这边其实是这样的:设置显示模板,主窗口是很多条款,比如,物品名称,物品价格,物品描述,物品产地等等,每个条款下有相关hidden类型的input,然后后面是"类型选择"链接,打开副窗口是属性页面,如字体,大小,颜色等等; 
    每次点击类型选择打开副窗口,选择属性后返回,
    最后按确认,把每个条款的相关属性存入DB中
      

  7.   

    有一点,上面的例子中子窗口是已知父窗口的ID或Name值了:
    window.opener.txtMain.value=txtSub.value; 
    但这里需要有可能txtMain不固定; 
    也就是第一次是这样:window.opener.txtMain.value=txtSub.value
    另一次需要赋的是:  window.opener.bakMain.value=txtSub.value
      

  8.   

    --------- Scl_main.asp --------<%
       Dim strTT1
       If Request.Form("TT1") <> "" Then
         strTT1 = Trim(Request.Form("TT1"))
       Else
         strTT1  = "大连理工大学"
       End If
    %><html>
      <head>
        <title>Login</title>
        <script language="javascript">
        <!--
          function Win_open()
          {
            window.open("Scl_sub.asp",'newwindow', 'height=100, width=400, top=0,left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no');
           }
        //-->
        </script>
      </head>
      <body>
        <form name="form1">
          <table>
            <tr>
              <td>
                <input type="buttom" name="B1" value="修改" onclick="Win_open();">
              </td>
              <td>
                学校名称:<input name="T1" size="30" value="<%= strTT1 %>" disabled>
              </td>
            </tr>
          </table>
        </form>
      </body>
    </html>-------- Scl_sub.asp ----------<html>
      <head>
        <title>PhoneCode</title>
        <script language="javascript">
        <!--
          function Win_close()
          {
            if (document.form1.TT1.value == '')
            {
              alert(" 必須填学校名!");
            }
            else
            {
              form1.method = 'post';
              form1.target='_self';
              form1.action='Scl_main.asp';
              form1.submit();
              alert("学校名修改成功");
              window.close();
            }
          }
        //-->
        </script>
      </head>
      <body>
        <form name="form1">
          <table>
            <tr>
              <td>
                <input type="submit" name="B1" value="提交" onclick="Win_close();">
              </td>
            </tr>
            <tr>
              <td>
                请输入学校名:
              </td>
              <td>
                <input type="text" name="TT1" size="20">
              </td>
            </tr>
          </table>
        </form>
      </body>
    </html>