Php 无法在没有响应的情况下将值从子页传递到父页
我有一个扩展名为.php的父和子页面。看来我的代码是正确的。但当我单击子页面上的“提交”按钮时,子页面将不会关闭,并且单元格表中的值无法传递到父页面上的文本字段中。代码如下: 父页面的代码: 子页面的代码parrent.php:Php 无法在没有响应的情况下将值从子页传递到父页,php,jquery,html,mysql,popupwindow,Php,Jquery,Html,Mysql,Popupwindow,我有一个扩展名为.php的父和子页面。看来我的代码是正确的。但当我单击子页面上的“提交”按钮时,子页面将不会关闭,并且单元格表中的值无法传递到父页面上的文本字段中。代码如下: 父页面的代码: 子页面的代码parrent.php: 好吧,我在失去时间前得到了答案。这是我的正确代码: <!doctype html public "-//w3c//dtd html 3.2//en"> <html> <head> <script langauge="javasc
好吧,我在失去时间前得到了答案。这是我的正确代码:
<!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("Gagal terkoneksi dengan database");
mysql_select_db("$db_name")or die("Tidak bisa memilih database");
$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。但该值无法传递给父页,且子页无法关闭。
<!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>
<!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("Gagal terkoneksi dengan database");
mysql_select_db("$db_name")or die("Tidak bisa memilih database");
$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>