how do i submit that option picked in the first combo box back to the page, grab it, query it again, and output the javascript options instead of the predefined options below?
Code: Select all
<form name="myform">
<select name="optone" size="1" onchange="setOptions(document.myform.optone.options[document.myform.optone.selectedIndex].value);">
<option value=" " selected="selected">Select Dept</option>
<?php
include("conection.php");
$query = "select DISTINCT(e_dept) from tbl_emp";
$result = mysql_query($query);
$num_results = mysql_num_rows($result);
for ($i=0; $i <$num_results; $i++)
{
$row = mysql_fetch_array($result);
$e_dept = $row['e_dept'];
?>
<option value="<?php echo $i; ?>"> <?php echo $e_dept; ?> </option>
<?php } ?>
</select>
<br /> <br />
<select name="opttwo" MULTIPLE>
<option value=" " selected="selected">Please select one of the options above first</option>
</select>note: i put $i for a selection option just to get the example to spit something out for the next combo box/
here is the javascript..
Code: Select all
function setOptions(chosen) {
var selbox = document.myform.opttwo;
selbox.options.length = 0;
if (chosen == " ") {
selbox.options[selbox.options.length] = new Option('Please select one of the options above first',' ');
}
if (chosen == "1") {
selbox.options[selbox.options.length] = new Option('first choice - option one','oneone');
selbox.options[selbox.options.length] = new Option('first choice - option two','onetwo');
}
if (chosen == "2") {
selbox.options[selbox.options.length] = new Option('second choice - option one','twoone');
selbox.options[selbox.options.length] = new Option('second choice - option two','twotwo');
}
if (chosen == "3") {
selbox.options[selbox.options.length] = new Option('third choice - option one','threeone');
selbox.options[selbox.options.length] = new Option('third choice - option two','threetwo');
}
}i have searched and searched.. even got sugessted to use AJAX.
can anyone point me in the right direction this is driving me crazy!