dougu5950 2015-12-05 06:08
浏览 197
已采纳

从另一个带有返回值的html页面关闭DIV

I have a php web page which has a textbox. beside the textbox i have provided a link. On clicking a link DIV open which has a ifram. I frame is populated with a list of items with id and description. Now when I click a particular Item I want the DIV to get closed and ID of that particular item to be fetched into the textbox.

Page1.php

<html>
<body>


<input id="productid" type="text" name="productID" />
        <img src=search.gif border=1 onclick="document.all.floatDiv.style.display='inline'" alt="Expand">
        <img src=nosearch.gif onclick="document.all.floatDiv.style.display='none'" alt="Compress">

        <div id="floatDiv">
            <iframe name="moreIframe" id="moreIframe" width="99%" height="97%" align="center" src="Page2.php" style="background-color: white;"></iframe>
            <?php
            ?>
        </div>

</body>
</html>

Page2.php

<html>
<body>

<table>
    <tr>
        <td>ID</td>
        <td>Product</td>
    </tr>

    <tr>
        <td><a href="" onclick="retvalue('12')" >12</a></td>
        <td>Brass 13 mm Rod</td>
    </tr>
    <tr>
        <td><a href="" onclick="retvalue('15')" >15</a></td>
        <td>Steel 13 mm Rod</td>
    </tr>
<table>

</body>
</html>
  • 写回答

3条回答 默认 最新

  • dongtaotao19830418 2015-12-07 06:02
    关注

    I found the answer as below.

    Page1.php

    <html>
    <style>
    #floatDiv {
        position:absolute;
        left:50%;
        margin-top:200px;
        margin-left:-200px;
        width:600px;
        height:200px;
        background-color: blue;
        display:none;
    }
    </style>
    
    <script language="javascript">
    function closediv()
    {
        document.getElementById('floatDiv').style='none';
    }
    </script>
    <body>
    
    <form name="form1" id="form2" method="post" >
    
    <input id="productid" type="text" name="productID" />
            <img src=search.gif border=1 onclick="document.all.floatDiv.style.display='inline'" alt="Expand">
            <img src=nosearch.gif onclick=" closediv();" alt="Compress">
    
    
            <div id="floatDiv">
                <iframe name="moreIframe" id="moreIframe" width="99%" height="97%" align="center" src="Page2.php?fldnm=productID" style="background-color: white;"></iframe>
                <?php
                ?>
            </div>
    </form>
    </body>
    </html>
    

    and page2.php

    <html>
    <head>
    <script language="javascript">
    function CloseWin(varv,elem)
    {
        parent.document.forms['form1'].elements[elem].value=varv;
        parent.closediv();
    
    }   
    </script>
    </head>
    <body>
    <table>
        <tr>
            <td>ID</td>
            <td>Product</td>
        </tr>
    
        <tr>
            <td><a class='test' href="" id="id1" onclick="kickass('12','productID');">12</a></td>
            <td>Brass 13 mm Rod</td>
        </tr>
        <tr>
            <td><a href="" class='test'  onclick="kickass('15','productID');">15</a></td>
            <td>Steel 13 mm Rod</td>
        </tr>
    <table>
    
    <html>
    <body>
    

    It does close the div containing the iframe and passed value in the textbox productID.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)