Hi
i am creating a form and I want the fields to update based on a previous fields selection.
I have dropdown Lists(Car Make & Car Model) on same web form. This dropdwon List are primarily populated by the fields MySql datababse. I would like to query MySql database based on the selection i make in those dropdown lists. But the most important functionality i would like here is ie If i make my selection in Car Make list, i want the Car Model dropdown list to be automatically reupdated based on the Car Make selection.
can any one point me in the right direction ?
thanks
multiple drop down Lists update on same form
Moderator: General Moderators
- raghavan20
- DevNet Resident
- Posts: 1451
- Joined: Sat Jun 11, 2005 6:57 am
- Location: London, UK
- Contact:
lets assume you have a select input control
hope this works.
if you have got time, then you can try javascript with xmlhttp.
Code: Select all
<form name = 'frmCars' method = 'post' action = '#'>
<select name = 'slCars' onchange = 'javascript:form.submit();'>
<option value = 'BMW'>BMW</option>
<option value = 'Jaguar'>Jaguar</option>
<option value = 'Bentley'>Bentley</option>
<option value = 'Mazda'>Mazda</option>
</select>
<select name = 'carModels'>Code: Select all
<?php
$query = 'select models from Cars where car_id = {$_POST["slCars"]}'
$result = mysql_query($query);
if (is_resource($result)){
if(mysql_num_rows($result)){
while(row = mysql_fetch_row($result)){
echo "<option value = '{$row[0]}'>$row[0]</option>";
}
}
}
?>Code: Select all
</select>
</form>if you have got time, then you can try javascript with xmlhttp.
Last edited by raghavan20 on Fri Sep 09, 2005 6:21 am, edited 1 time in total.
- harrisonad
- Forum Contributor
- Posts: 288
- Joined: Fri Oct 15, 2004 4:58 am
- Location: Philippines
- Contact:
That's sounds like client-side, take a look at codergoblin's tutorial:
viewtopic.php?t=29084
viewtopic.php?t=29084