我的需求是:在a页面中,选中下拉菜单中的一个值,会弹出一个新页面b;在新页面b中单击一个超级连接,将表单中的值传到a页面的同时,新页面b关闭。a 页面通过传来的值,刷新后,显示查询的内容。
a页面,下拉菜单如下:<select id="select_user" name="select_user">
                <option value="0">--无--</option>
                <?php
                    while($user_object=mysql_fetch_object($user_resource)){
                        echo "<option value='".$user_object->uId."'>".$user_object->userName."</option>";
                    }
                ?>
            </select>新页面b如下:<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>aa</title>
        <script type="text/javascript">
            //取消按钮的操作
            function setClose(){
                window.close();
            }
            //传递编号
            function send(){
                document.getElementById("addrole_form").action="a.php";
                document.getElementById("addrole_form").submit();
            }
        </script>
    </head>
    <body>
        <div id="content" style="width: 100%; height: 100%;">
            <h1 style="font-weight: bold; font-size: 15px;">角色:</h1>
            <div id="cancel" style="width: 100%; height: 5%;">
                <input type="button" id="role_calcel" name="role_cancel" value="取 消" title="取消" onclick="javascript:setClose();"
                       style="border: 1px solid; background-color: #EFFCFE; border-color: #4DA0F4;"/>
            </div>
            <form id="addrole_form" method="post" action="#">
                <table border="1" cellpadding="0" cellspacing="0"  width="100%"
                       style="border: 1px solid; border-color: #4DA0F4; border-collapse: collapse; border-top-color: #377CF0; border-top-width: medium;">
                    <tbody>
                        <tr>
                            <td bgcolor="#e6faff">角色名称</td>
                            <td bgcolor="#e6faff">角色描述</td>
                        </tr>
                        <?php
                            while($object=mysql_fetch_object($resource)){
                        ?>
                        <tr>
                            <td>
                                <a id="role<?php echo $object->roleId; ?>" href="#" onclick="javascript:send();">
                                    <?php echo iconv("gb2312","utf-8","$object->roleName"); ?>
                                </a>
                                <input type="hidden" id="roleid" name="roleid" value="<?php echo $object->roleId; ?>" />
                            </td>
                            <td><?php echo iconv("gb2312","utf-8","$object->rDescription"); ?></td>
                        </tr>
                        <?php
                            }
                        ?>
                    </tbody>
                </table>
            </form>
        </div>
    </body>
</html>

解决方案 »

  1.   

    是不是要这个效果?
    页面1
    <html>
    <body>
    <input type="button" value="打开" onclick="window.open('b.html');" />
    <div id="div_1">关闭新页面后看这里</div>
    </body>
    </html>
    页面2
    <html>
    <script>
    function _oper(values){
    window.opener.document.getElementById("div_1").innerHTML=values;
    window.close();
    }
    </script>
    <body>
    <a href="javascript:_oper(123);">点击关闭</a>
    </body>
    </html>
      

  2.   

    可以用url?id="什麽" 获取id的值.
    get提交方式...<html>
    <body>
    <input type="button" value="打开" onclick="window.open('b.php?id=1');" />
    <div id="div_1">关闭新页面后看这里</div>
    </body>
    </html>
      

  3.   

    把楼上的改了一下,应该满足你的要求了...----------------------------------------------
    <?php
    if(!empty($_POST['search'])){
    echo 'searching...'.$_POST['search'];
    }else{
    echo '...';
    }
    ?>
    <html>
    <body>
    <input type="button" value="open" onclick="window.open('t11_2.php');" />
    <form id="tform" method="post">
    <input type="hidden" id="div_1" name="search" value=""/>
    </form>
    </body>
    </html>-----------------------------<html>
    <script>
    function _oper(values){
    window.opener.document.getElementById("div_1").value=document.getElementById("n").value;
    window.opener.document.getElementById("tform").submit();
    window.close();
    }
    </script>
    <body>
    <form id="aform" method="post">
    <a href="javascript:_oper();">close</a>
    <input type="text" id="n" name="n" value="just a test" />
    </form>
    </body>
    </html>