Help with auto populating a dropdown for form
I know you can populate a form dropdown with data from a database based on the selection of another dropdown with Ajax.
I don't have any experience with Ajax, but I need to get this project done for my work.
If anyone cane help me with this I'd really appreciate it.
Here is the code for my first dropdown.
PHP Code:
<?php
$flight_sql = "SELECT * FROM wp_flr_flights";
$flight_result = mysql_query($flight_sql);
echo '<select name="location">';
while ($flt_loc_rows = mysql_fetch_assoc($flight_result)) {
$loc_id = $flt_loc_rows["location_id"];
$loc_name = $flt_loc_rows["location_name"];
echo ''<option value="'.$loc_id.'">'.$loc_name.'</option>'';
}
echo '</select>';
?>
So what I want to happen, is when the dropdown is selected the next three dropdowns on the form are populated based in the $loc_id variable.
SO every row in the table with (let's say) and $loc_id of 1. The form gets populated on with information from those rows.
I hope that make sense. I apologize if I posted in the wrong area. I'm not sure if this should be PHP or JavaScript.
Thanks in advanced