I'm having a slight problem. I have a form with 2 drop down boxes generated from a mysql database. This is no problem.
What I need it to do is this: when a value is chosen from the first drop down box I need the second one to show the selected value that corresponds to the id from the first.
here is the code to generate the boxes
I hope this is clear.
I believe that I need to use Javascript with an onchange event but have no idea how to implement it.
any help will be greatly appreciated.
What I need it to do is this: when a value is chosen from the first drop down box I need the second one to show the selected value that corresponds to the id from the first.
here is the code to generate the boxes
Code:
<?php
<select name='class' id='class' >";
$query='SELECT DISTINCT class_id, class_number
FROM tblClass_Details';
$result=mysql_query($query);
?>
<option selected value='0'>Select</option>
<?php while ($current_record=mysql_fetch_array($result)) {
$id=$current_record['class_id'];
$number=$current_record['class_number'];
?> <option value='$id'>$number</option>
<?php }
?>
</select>
<select name='teacher' id='teacher'>
<?php
$query='SELECT DISTINCT teacher_id, first_name,last_name FROM tblTeacher';
$result=mysql_query($query);
?><option selected value='0'>Select</option>";
<?php while ($current_record=mysql_fetch_array($result)) {
$id=$current_record['teacher_id'];
$first=$current_record['first_name'];
$last=$current_record['last_name'];
?>
<option value='$id'>$first $last</option>
<?php }
?> </select>
I believe that I need to use Javascript with an onchange event but have no idea how to implement it.
any help will be greatly appreciated.