http://whodateswhere.com/auto/
This is my site I’m building.
Where it shows:
Make:
Model:
I’d like to know, after the first is chosen, how do I let the second drop down know it will be from that make?
Here is the code:
<script type="text/javascript">
$(function(){
$.get('makes_models.php', function(data){
$('#ajax_make_select').html( data );
});
// on change of dropdown1 populate dropdown2 with the respective data
$('#ajax_make_select').change(function(){
$.get('models.php',{ make: $('ajax_make_select').val() }, function(data){
$('#ajax_model_select').html( data );
});
});
});
</script>
with the makes_models.php code is:
<select>
<option value=999>Select a Make</option>
<option value=1>Acura</option>
<option value=2>Audi</option>
<option value=3>BMW</option>
</select>
How would I go about coding the second file? “models.php”
if Acura is chosen, I would like it to display
<option value=1>MDX</option>
<option value=2>RDX</option>
<option value=3>RL</option>
<option value=4>TL</option>
<option value=5>TSX</option>
<option value=6>ZDX</option>
I suggest you check out my answer here.
http://jsfiddle.net/tBrXt/2/
In response to how you would code the second file, use the
switch/casestatement: