0
我有一個帶.php擴展名的父頁面和子頁面。看來我的代碼是正確的。但是當我點擊子頁面上的提交按鈕時,子頁面不會關閉,並且我的單元格表格中的值無法傳遞到父頁面上的文本字段。下面是代碼:未能將值從子頁面傳遞到沒有響應的父頁面
父頁面的代碼:
<html>
<head>
</head>
<body>
<form method=post action='' name='f1'>
<font size=2 face='Verdana'>Your Name</font><input type=text name='p_name' size='8'> <a href="javascript:void(0);" NAME="My Window Name" title=" My title here " onClick=window.open("target.php","Ratting","width=1000,height=500toolbar=1,status=1,");>Click here to open the child window</a>
</form>
</body>
</html>
子頁面的代碼(parrent.php):
<!doctype html public "-//w3c//dtd html 3.2//en">
<html>
<head>
<script langauge="javascript">
function post_value(id){
opener.document.f1.p_name.value = document.forms[id].c_name.value;
self.close();
}
</script>
</head>
<body>
<?php
$host="localhost";
$username="root";
$password="";
$db_name="rawatinap";
mysql_connect("$host", "$username", "$password")or die("failed db connection");
mysql_select_db("$db_name")or die("cannot select db");
$edit = mysql_query("SELECT id_obat from obat");
?>
<table >
<?php
$id=0;
while($rows=mysql_fetch_array($edit)){
echo " <form name=$id method='post' action=''><tr>
<td><input type=\"text\" name=\"c_name\" size=\"30\" value=\"$rows[id_obat]\" /></td>
<td><input type=button value='Submit' onclick='post_value('$id')</td></tr>
</form>";
$id++;
}
?>
</table>
</body>
</html>
你想要達到什麼目的? –
@ManojPurohit只需將子頁面上的表格單元格「c_name」的值傳遞到父頁面上的文本「p_name」即可。但是,該值不能傳遞給父頁面,並且子頁面無法關閉。 –