这是我的Parent.php窗口.........
<html>
<body>
<form name="parentForm"><input name="toppings" value="" /><a href="javascript:void(0);" NAME="My Window Name" title=" My title here " onClick=window.open("toppings.php","popup","width=550,height=170,left=150,top=200,toolbar=1,status=1,");>Search</a></form>
</body>
</html>
这是我的Child.php窗口........
<?php
include("config.php");
//---------------------------------------------
$department = $_GET['department'];
$headoffice = $_GET['headoffice'];
$office = $_GET['office'];
$designation = $_GET['designation'];
if(!empty($department))
{
if(!empty($headoffice))
{
if(!empty($office))
{
if(!empty($designation))
{
$sql = "SELECT * FROM user WHERE designation='$designation'";
}
else
{
$sql = "SELECT * FROM user WHERE office='$office'";
}
}
else
{
$sql = "SELECT * FROM user WHERE headoffice='$headoffice'";
}
}
else
{
$sql = "SELECT * FROM user WHERE department='$department'";
}
}
else
{
$sql = "SELECT * FROM user";
}
$result=mysql_query($sql);
$count=mysql_num_rows($result);
?>
<html>
<head>
<script type="text/javascript">
<!--
function updateParent() {
s = "";
for (i = 0; i < 7; i++)
{
chk = eval("self.document.childForm.t" + i);
if (chk.checked)
s += chk.value + ", ";
}
window.opener.document.parentForm.toppings.value = s;
self.close();
return false;
}
//-->
</script>
</head>
<body>
<form name="childForm" action="">
<p>Choose topping(s):
<table>
<?php
while($rows=mysql_fetch_array($result)){
?>
<tr><td>
<input type="checkbox" name="t0" value="<?php echo $rows['userid']; ?>" /></td><td><?php echo $rows['userid']; ?></td></tr>
<?php }?>
<tr><td></td><td><input type="submit" value="submit" onclick="updateParent();"/></td></tr></table>
</form>
</body>
</html>
它不能正常工作。子窗口复选框值不会在父窗口中传递,也不会自行关闭它。请帮忙。提前谢谢
答案 0 :(得分:0)
要获得child.php中的值,您需要提交表单。结帐代码如下:
<强> parent.php 强>
<form name="parentForm" action="child.php" method="GET">
<input type="text" name="department" />
<input type="text" name="headoffice" />
<input type="text" name="office" />
<input type="text" name="designation" />
</form>
的 child.php 强>
...
...
$department = $_GET['department'];
$headoffice = $_GET['headoffice'];
$office = $_GET['office'];
$designation = $_GET['designation'];
...
...
答案 1 :(得分:0)
您可以尝试会话。我不确定这些方法是&#34; post&#34;并且&#34;得到&#34;将所有值传递给弹出窗口。 (如果我错了,请纠正我)
<强> parent.php 强>
session_start();//at very top of the page
$_SESSION['department']; = $_GET['department'];
$_SESSION['headoffice']; = $_GET['headoffice'];
$_SESSION['office']; = $_GET['office'];
$_SESSION['designation']; = $_GET['designation'];
<强> child.php 强>
session_start();//at very top of the page
$department=$_SESSION['department'];
$headoffice=$_SESSION['headoffice'];
$office=$_SESSION['office'];
$designation=$_SESSION['designation'];