2012-08-23 245 views
1

大家好我是新來的PHP,想知道如果可以從一個包含數據庫中數據的表的子窗口傳遞數據,並選擇哪些數據使用子窗口內的複選框將值回顯到父窗口的文本區域。如果有人能夠提供一些幫助,我將非常感激。以下是代碼。謝謝。PHP將數據從子窗口傳遞到父窗口

子窗口:

<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']; 
} 
?> 

父窗口:

<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

你的父窗口可以通過「window.opener」 here是如何從孩子將數據發送到一個例子進行訪問父窗口。

+0

非常感謝。我會研究這一點。 – user1610834

相關問題