asherinho
09-04-2008, 01:36 PM
hi! Can u please tell me whats wrong with my codes cause it doesn't work and I don't see where I went wrong.I have a page with two select fields where the second select field is populated with the values depending on the selection made in the first field.And this page refers to a php page which I refered it as a javascript page as shown below
<html>
<head>
<title>Chained Selects</title>
<script language="javascript" src="chainedselects.js"></script>
<script type="text/javascript" src="reference.php"></script>
</head>
<body onload="initListGroup('vehicles', document.forms[0].make, document.forms[0].type, document.forms[0].model, 'cs')">
<form>
<table align="center"><tr>
<td>Select a vehicle: </td>
<td><select name="make" style="width:160px;"></select></td>
<td><select name="type" style="width:160px;"></select></td>
<td><input type="button" value="Reset" onclick="resetListGroup('vehicles')">
</tr></table>
</form>
</body>
</html
The values to be filled in these select fields are obtained from reference.php which runs javascript codes as shown below
<?
header("content-type:application/javascript");
echo "
var disable_empty_list=true;<br>
addListGroup(\"vehicles\", \"car-makers\");<br>
addOption(\"car-makers\", \"Select vehicle\", \"\", \"\", 1); <br>
addList(\"car-makers\", \"Toyota\", \"Toyota\", \"Toyota\");<br>
addList(\"car-makers\", \"Nissan\", \"Nissan\", \"Nissan\");<br>
addOption(\"Toyota\", \"Select maker\", \"\", \"\", 1);<br>
addList(\"Toyota\", \"\");<br>
addList(\"Toyota\", \"Hilux\");<br>
addList(\"Toyota\", \"Land cruser\");<br>
addOption(\"Nissan\", \"select maker\", \"\", \"\", 1);<br>
addList(\"Nissan\", \Safari\");<br>
addList(\"Nissan\", \"Hard body\");<br>
addList(\"Nissan\", \"Terrano\");
";
?>
Whats wrong with this reference.php page?
<html>
<head>
<title>Chained Selects</title>
<script language="javascript" src="chainedselects.js"></script>
<script type="text/javascript" src="reference.php"></script>
</head>
<body onload="initListGroup('vehicles', document.forms[0].make, document.forms[0].type, document.forms[0].model, 'cs')">
<form>
<table align="center"><tr>
<td>Select a vehicle: </td>
<td><select name="make" style="width:160px;"></select></td>
<td><select name="type" style="width:160px;"></select></td>
<td><input type="button" value="Reset" onclick="resetListGroup('vehicles')">
</tr></table>
</form>
</body>
</html
The values to be filled in these select fields are obtained from reference.php which runs javascript codes as shown below
<?
header("content-type:application/javascript");
echo "
var disable_empty_list=true;<br>
addListGroup(\"vehicles\", \"car-makers\");<br>
addOption(\"car-makers\", \"Select vehicle\", \"\", \"\", 1); <br>
addList(\"car-makers\", \"Toyota\", \"Toyota\", \"Toyota\");<br>
addList(\"car-makers\", \"Nissan\", \"Nissan\", \"Nissan\");<br>
addOption(\"Toyota\", \"Select maker\", \"\", \"\", 1);<br>
addList(\"Toyota\", \"\");<br>
addList(\"Toyota\", \"Hilux\");<br>
addList(\"Toyota\", \"Land cruser\");<br>
addOption(\"Nissan\", \"select maker\", \"\", \"\", 1);<br>
addList(\"Nissan\", \Safari\");<br>
addList(\"Nissan\", \"Hard body\");<br>
addList(\"Nissan\", \"Terrano\");
";
?>
Whats wrong with this reference.php page?