My code is below. On changing the first drop-down box the second drop-down box is dynamically filled with the relevant data. The listings are generated through PHP linking to MySQL within the JavaScript code.
The problem is that I am using this form in order to search a MySQL database. The select field 'type' is not used correctly as a variable in the sql query on the results page. No results appear on screen when using the value in the 'type' select box. I have found that when I omit onChange="fillState(this.form); it can be correctly used. Ha anybody got a workaround for this? Thanks...
===========================================
===========================================
<html>
<head>
<title>Helpdesk</title>
<link rel="stylesheet" type="text/css" href="hdstyle.css">
<script language="Javascript">
function fillState(form) {
if (form.type.selectedIndex == "1") {
form.state.options.length = 0;
form.state.options[1] = new Option("SCFHNT5", "SCFHNT5");
form.state.options[2] = new Option("SCFHNT8", "SCFHNT8");
form.state.options[3] = new Option("SCFHNT9", "SCFHNT9");
}
else if (form.type.selectedIndex == "2") {
form.state.options.length = 0;
form.state.options[1] = new Option("Lime", "Lime");
form.state.options[2] = new Option("Orange", "Orange");
}
}
</script>
</head>
<body>
<div align="center">
<div align="center"><h1>ITU Network Changes</h1><OBJECT classid="clsid
27CDB6E-AE6D-11cf-96B8-444553540000" codebase="shockwave/cabs/flash/swflash.cab#version=4,0,2,0" width="843" height="47">
<PARAM name="movie" value="Starlight.swf">
<PARAM name="quality" value="high">
<PARAM name="menu" value="true">
<EMBED src="Starlight.swf" quality="high" menu="true" pluginspage="download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="843" height="47">
</EMBED>
</OBJECT></div>
<form action="search_id.php" method="post">
<table border="4"
bordercolorlight="#c6e7de"
bordercolordark="#31ada5"
>
<tr>
<td align="left">
<b>Unique Number </b><input type="text" name="id" size="10"></td>
<td width="25%" align="left">
<input type="submit" name="submit" value="Submit"></td>
</tr>
</table>
</form>
<br>
<br>
<h3>Advanced Search</h3>
<form action="search_script.php" method="post">
<table border="3" bordercolorlight="#c6e7de" bordercolordark="#31ada5">
<tr>
<td width="121" height="35">Type</td>
<td width="180" height="35"> <select name="type" onChange="fillState(this.form);">
<option value="none">-- choose one --</option>
<option value="Server">Server</option>
<option value="Coms">Coms</option>
</select></td>
<td width="59" height="35">List</td>
<td height="35" colspan="3"> <select name="state">
<option value="none">-- choose one --</option>
</select> </td>
</tr>
<tr>
<td height="35">Assigned To</td>
<td height="35"> <select name="assignedto" size="1">
<option value="none">-- choose one --</option>
<option value="Jon Jehan">Jon Jehan</option>
<option value="Pierre Humphries">Pierre Humphries</option>
<option value="Neil Martin">Neil Martin</option>
<option value="John Fitzpatrick">John Fitzpatrick</option>
<option value="Kevin Austin">Kevin Austin</option>
<option value="Ian Maxey">Ian Maxey</option>
<option value="Mat Ewins">Mat Ewins</option>
<option value="Marcus Jehan">Marcus Jehan</option>
<option value="Chris Harvey">Chris Harvey</option>
<option value="Dan Le Poidevin">Dan Le Poidevin</option>
<option value="Richard Elliott">Richard Elliott</option>
<option value="Sam Holland">Sam Holland</option>
<option value="Wayne Robert">Wayne Robert</option>
<option value="Peter Doyle">Peter Doyle</option>
</select></td>
<td height="35">Status</td>
<td height="35"> <select name="status" size="1">
<option value="none">-- choose one --</option>
<option value="Request">Request</option>
<option value="Complete">Complete</option>
</select> </td>
<td height="35">Change Type</td>
<td height="35"> <select name="changetype" size="1">
<option value="none">-- choose one --</option>
<option value="System Configuration">System Configuration</option>
<option value="Update">Update</option>
</select> </td>
</tr>
<tr>
<td height="5" colspan="6"></td>
</tr>
<tr>
<td height="35" colspan="6">Notes</td>
</tr>
<tr>
<td colspan="6" align="center"><textarea name="notes" cols="75" rows="5"></textarea></td>
</tr>
<tr>
<td height="5" colspan="6"></td>
</tr>
<tr align="center">
<td height="40" colspan="6">
<input type="submit" name="Submit" value="Submit">
<input type="reset" name="Submit" value="Reset">
</td>
</tr>
</table>
</center>
</form>
</div>
</body>
</html>
===========================================
===========================================
================================
"Chaos, panic & disorder - my work here is done!"
================================
The problem is that I am using this form in order to search a MySQL database. The select field 'type' is not used correctly as a variable in the sql query on the results page. No results appear on screen when using the value in the 'type' select box. I have found that when I omit onChange="fillState(this.form); it can be correctly used. Ha anybody got a workaround for this? Thanks...
===========================================
===========================================
<html>
<head>
<title>Helpdesk</title>
<link rel="stylesheet" type="text/css" href="hdstyle.css">
<script language="Javascript">
function fillState(form) {
if (form.type.selectedIndex == "1") {
form.state.options.length = 0;
form.state.options[1] = new Option("SCFHNT5", "SCFHNT5");
form.state.options[2] = new Option("SCFHNT8", "SCFHNT8");
form.state.options[3] = new Option("SCFHNT9", "SCFHNT9");
}
else if (form.type.selectedIndex == "2") {
form.state.options.length = 0;
form.state.options[1] = new Option("Lime", "Lime");
form.state.options[2] = new Option("Orange", "Orange");
}
}
</script>
</head>
<body>
<div align="center">
<div align="center"><h1>ITU Network Changes</h1><OBJECT classid="clsid

<PARAM name="movie" value="Starlight.swf">
<PARAM name="quality" value="high">
<PARAM name="menu" value="true">
<EMBED src="Starlight.swf" quality="high" menu="true" pluginspage="download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="843" height="47">
</EMBED>
</OBJECT></div>
<form action="search_id.php" method="post">
<table border="4"
bordercolorlight="#c6e7de"
bordercolordark="#31ada5"
>
<tr>
<td align="left">
<b>Unique Number </b><input type="text" name="id" size="10"></td>
<td width="25%" align="left">
<input type="submit" name="submit" value="Submit"></td>
</tr>
</table>
</form>
<br>
<br>
<h3>Advanced Search</h3>
<form action="search_script.php" method="post">
<table border="3" bordercolorlight="#c6e7de" bordercolordark="#31ada5">
<tr>
<td width="121" height="35">Type</td>
<td width="180" height="35"> <select name="type" onChange="fillState(this.form);">
<option value="none">-- choose one --</option>
<option value="Server">Server</option>
<option value="Coms">Coms</option>
</select></td>
<td width="59" height="35">List</td>
<td height="35" colspan="3"> <select name="state">
<option value="none">-- choose one --</option>
</select> </td>
</tr>
<tr>
<td height="35">Assigned To</td>
<td height="35"> <select name="assignedto" size="1">
<option value="none">-- choose one --</option>
<option value="Jon Jehan">Jon Jehan</option>
<option value="Pierre Humphries">Pierre Humphries</option>
<option value="Neil Martin">Neil Martin</option>
<option value="John Fitzpatrick">John Fitzpatrick</option>
<option value="Kevin Austin">Kevin Austin</option>
<option value="Ian Maxey">Ian Maxey</option>
<option value="Mat Ewins">Mat Ewins</option>
<option value="Marcus Jehan">Marcus Jehan</option>
<option value="Chris Harvey">Chris Harvey</option>
<option value="Dan Le Poidevin">Dan Le Poidevin</option>
<option value="Richard Elliott">Richard Elliott</option>
<option value="Sam Holland">Sam Holland</option>
<option value="Wayne Robert">Wayne Robert</option>
<option value="Peter Doyle">Peter Doyle</option>
</select></td>
<td height="35">Status</td>
<td height="35"> <select name="status" size="1">
<option value="none">-- choose one --</option>
<option value="Request">Request</option>
<option value="Complete">Complete</option>
</select> </td>
<td height="35">Change Type</td>
<td height="35"> <select name="changetype" size="1">
<option value="none">-- choose one --</option>
<option value="System Configuration">System Configuration</option>
<option value="Update">Update</option>
</select> </td>
</tr>
<tr>
<td height="5" colspan="6"></td>
</tr>
<tr>
<td height="35" colspan="6">Notes</td>
</tr>
<tr>
<td colspan="6" align="center"><textarea name="notes" cols="75" rows="5"></textarea></td>
</tr>
<tr>
<td height="5" colspan="6"></td>
</tr>
<tr align="center">
<td height="40" colspan="6">
<input type="submit" name="Submit" value="Submit">
<input type="reset" name="Submit" value="Reset">
</td>
</tr>
</table>
</center>
</form>
</div>
</body>
</html>
===========================================
===========================================
================================
"Chaos, panic & disorder - my work here is done!"
================================