This is probably more a javascript, or even an html problem...but I'm guessing php is might be the culprit. I have a parent form that opens a popup and runs a query on the database and the record that is chosen, the id is passed to the parent form. When the query returns one choice, everything works fine; the id is passed correctly. When the query returns multiple choices, "undefined" is returned to the parent. Please help me figure this one out.
PHP:
parent form:
<html>
<head>
<script language="JavaScript"><!--
function newWindow(file,window) {
msgWindow=open(file,window,'resizable=yes,width=600,height=400');
if (msgWindow.opener == null) msgWindow.opener = self;
}
//--></script>
</head>
<body>
<center>
<form name="outputForm1">
<input type="button" value="Open formb.htm into window2" onClick="newWindow('formb.htm','window2')">
<input name="outputField1" type="text" value="">
</form>
</body>
</html>
formb.htm:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body>
<form name="form1" method="post" action="reaction8.php">
Doctor Last Name
<input name="LastName" type="text" id="LastName">
<input type="submit" name="Submit" value="Submit">
</form>
</body>
</html>
reaction8.php:
<?php require_once('Connections/dmeco.php'); ?>
<?php
$maxRows_Recordset1 = 10;
$pageNum_Recordset1 = 0;
if (isset($GET['pageNum_Recordset1'])) {
$pageNum_Recordset1 = $GET['pageNum_Recordset1'];
}
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;
$colname_Recordset1 = "1";
if (isset($POST['LastName'])) {
$colname_Recordset1 = (get_magic_quotes_gpc()) ? $POST['LastName'] : addslashes($_POST['LastName']);
}
mysql_select_db($database_dmeco, $dmeco);
$query_Recordset1 = sprintf("SELECT DoctorID, UPIN, FirstName, LastName, AddressLine1, AddressLine2, City, State, ZIP FROM doctors WHERE LastName LIKE '%s%%'", $colname_Recordset1);
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $dmeco) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
if (isset($GET['totalRows_Recordset1'])) {
$totalRows_Recordset1 = $GET['totalRows_Recordset1'];
} else {
$all_Recordset1 = mysql_query($query_Recordset1);
$totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
}
$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<script language="JavaScript"><!--
function setForm() {
opener.document.outputForm1.outputField1.value = document.inputForm1.inputField1.value;
self.close();
return false;
}
//--></script>
</head>
<body>
<form name="inputForm1" onSubmit="return setForm();">
<table border="1">
<tr>
<td></td>
<td></td>
<td>DoctorID</td>
<td>UPIN</td>
<td>FirstName</td>
<td>LastName</td>
<td>AddressLine1</td>
<td>AddressLine2</td>
<td>City</td>
<td>State</td>
<td>ZIP</td>
</tr>
<?php do { ?>
<tr>
<td><input type="submit" value="Update opener"></td>
<td><input name="inputField1" type="radio" value="<?php echo $row_Recordset1['DoctorID']; ?>"></td>
<td><?php echo $row_Recordset1['DoctorID']; ?></td>
<td><?php echo $row_Recordset1['UPIN']; ?></td>
<td><?php echo $row_Recordset1['FirstName']; ?></td>
<td><?php echo $row_Recordset1['LastName']; ?></td>
<td><?php echo $row_Recordset1['AddressLine1']; ?></td>
<td><?php echo $row_Recordset1['AddressLine2']; ?></td>
<td><?php echo $row_Recordset1['City']; ?></td>
<td><?php echo $row_Recordset1['State']; ?></td>
<td><?php echo $row_Recordset1['ZIP']; ?></td>
</tr>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</table>
Please type in the DoctorID.
<input type="submit" value="Update Order">
</form>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>