父页面上用JS弹出层(所谓的百度弹出登陆框的那个)弹出一个子页面 url ,在这个子页面上双击表格某行,就给父页面的表单文本框赋值,同时弹出层关闭,达到规范用户输入的目的。赋值这一块搞不定,请高手帮忙:
演示页面:http://pic.zttit.com/FloatLayer/
代码打包:http://pic.zttit.com/FloatLayer/FloatLayer.rar

解决方案 »

  1.   

    关闭窗口放到最后执行,要不关闭层后移除了DOM对象,再进行其他操作就报错了
    url.htm
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title></title>
    <style type="text/css">
    <!--
    body {
    font-size: 12px;
    margin: 40px;
    line-height: 24px;
    }
    table  { border-collapse: collapse; }
    td {
    border: #ccc 1px solid;
    line-height:22px;
    }
    th{
    line-height: 28px;
    background-color: #eee;
    border: #ccc 1px solid;
    }
    -->
    </style>
    <script>
        function setData(name, addr, age) {
            var doc = parent.document;
            doc.getElementById('textfield1').value = name;
            doc.getElementById('textfield2').value = addr;
            doc.getElementById('textfield3').value =age;
        }
    </script>
    </head>
    <body>
    此页面文件名为 url.htm ,双击表格行,将值赋给刚才的表单,同时弹出层关闭。<br />
    <table width="400" align="center" cellpadding="0" cellspacing="0" >
      <tr>
        <th align="center"><strong>姓名</strong></th>
        <th align="center"><strong>籍贯</strong></th>
        <th align="center"><strong>年龄</strong></th>
      </tr>
      <tr onDblClick="javascript:setData('张三','美国','12');parent.g_close_pop();">
        <td align="center">张三</td>
        <td align="center">美国</td>
        <td align="center">12</td>
      </tr>
      <tr onDblClick="javascript:setData('李四','英国','11');parent.g_close_pop();">
        <td align="center">李四</td>
        <td align="center">英国</td>
        <td align="center">11</td>
      </tr>
      <tr onDblClick="javascript:setData('王五','中国','15');parent.g_close_pop();">
        <td align="center">王五</td>
        <td align="center">中国</td>
        <td align="center">15</td>
      </tr>
    </table>
    </body>
    </html>
      

  2.   

    chrom中不能实现
    只支持ie
    index添加如下方法<script>
    function setData(name, jiguan, age){
        document.getElementById('textfield1').value = name;
            document.getElementById('textfield2').value = jiguan;
            document.getElementById('textfield3').value =age;
    }
    </script>
    url中添加如下方法:<script>
    function test(name, jiguan, age){
    parent.setData(name, jiguan, age);
    parent.g_close_pop();
    }
    </script>
    url中html代码改成如下形式: <tr onDblClick="test('张三', '美国', '12')">