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条)

报告相同问题?

悬赏问题

  • ¥20 iOS绕地区网络检测
  • ¥15 python验证码滑块图像识别
  • ¥15 根据背景及设计要求撰写设计报告
  • ¥15 QT6颜色选择对话框显示不完整
  • ¥20 能提供一下思路或者代码吗
  • ¥15 用twincat控制!
  • ¥15 请问一下这个运行结果是怎么来的
  • ¥15 单通道放大电路的工作原理
  • ¥30 YOLO检测微调结果p为1
  • ¥15 DS18B20内部ADC模数转换器