dongxing4805 2012-08-23 13:35
浏览 99
已采纳

PHP将数据从子窗口传递到父窗口

Hi everyone im new to php and would like to know how if it is possible to pass the data from a child window with a table containing data from the database and upon selection of which data to echo the value into the text area of the parent window using a checkbox within the child window.I would much appreciate it if anyone could provide some help on this. Below is the code. Thanks.

Child Window:

<head>
    <!-- CSS goes in the document HEAD or added to your external stylesheet -->
<!-- CSS goes in the document HEAD or added to your external stylesheet -->
<style type="text/css">
table.hovertable {
    font-family: verdana,arial,sans-serif;
    font-size:11px;
    color:#333333;
    border-width: 1px;
    border-color: #999999;
    border-collapse: collapse;
}
table.hovertable th {
    background-color:#c3dde0;
    border-width: 1px;
    padding: 8px;
    border-style: solid;
    border-color: #a9c6c9;
}
table.hovertable tr {
    background-color:#d4e3e5;
}
table.hovertable td {
    border-width: 1px;
    padding: 8px;
    border-style: solid;
    border-color: #a9c6c9;
}
</style>

<!-- Table goes in the document BODY -->

</head>
<body>
        <form action="retrievemath.php" method="post">
<table class="hovertable">
<tr>
    <th>Insert ?</th><th>Expression Name</th><th>Math Expression</th>
</tr>
<tr onmouseover="this.style.backgroundColor='#ffff66';" onmouseout="this.style.backgroundColor='#d4e3e5';">

</tr>

    <?php
               while($row = mysql_fetch_assoc($queryResource))
               {     
    ?>

                    <tr> 
                    <td><input type="radio" name="insert" id="<?php echo $row['mathID']?>" value="<?php echo $row['expressionname']?>" /> </td> 
                    <td><?php echo $row['expressionname']; ?></td>
                    <td><?php echo $row['mathexpression']; ?></td> 
                    </tr>

    <?php
               }
    ?>


</table>



    <div class="submit">
     <input type="hidden" name="formsubmitted" value="TRUE" />
      <input type="submit" value="Insert" />
    </div>
        </form>
</body>
<?php 
if (isset($_POST['formsubmitted'])) {
    echo $_POST['insert'];
}
?>

Parent Window:

<head>
<script type="text/javascript">
<!--
function myPopup2() {
window.open( "retrievemath.php", "myWindow", 
"status = 1, height = 300, width = 300, resizable = 0" )
}
//-->
</script>
<script src="ckeditor/ckeditor.js"></script>

</head>
<body>
    <textarea class="ckeditor" cols="80" id="editor1" name="editor1" rows="10" ></textarea>
<form>
<input type="button" onClick="myPopup2()" value="POP2!">
</form>
<p onClick="myPopup2()">CLICK ME TOO!</p>
</body>
  • 写回答

1条回答 默认 最新

  • ds342222 2012-08-23 13:43
    关注

    your parent window can be accessed by "window.opener" here is an example how you can send data from child to the parent window.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 matlab求解平差
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办
  • ¥15 vue2登录调用后端接口如何实现
  • ¥85 永磁型步进电机PID算法