what is a good way
Posted: Fri Feb 29, 2008 10:27 am
to make a dynamic drop down for when someone selects a country i need it to populate the states or counties list for each country that is choosen... and i have tried a dynamic drop down for javascript but i dont know how i would be able to get the java to query the database... Can someone help me please?
Heres my code for the drop downs:
And my database is set up like this for those 2 selects
--------------------------------------------------------------------
iso_countries iso_counties
id-------------------------+ id
iso +-----------country_id
printable_name abbrev
iso3 name
numcode
and the url for the javascript code i was trying to use is here
http://www.dynamicdrive.com/dynamicinde ... /index.htm
Heres my code for the drop downs:
Code: Select all
<strong>Country:</strong>
<select name="country" id="country" class="textbox">
<?php
$country = $db->select("SELECT * FROM cc_iso_countries");
for($i=0;$i<count($country); $i++){ ?>
<option id="<?php echo $country[$i]['numcode']; ?>" value="<?php echo $country[$i]['id']; ?>"><?php echo $country[$i]['printable_name']; ?></option>
<?php } ?>
</select>
<select name="state" id="state" class="textbox">
<?php
$country = $db->select("SELECT * FROM cc_iso_counties WHERE");
for($i=0;$i<count($country); $i++){ ?>
<option id="<?php echo $country[$i]['numcode']; ?>" value="<?php echo $country[$i]['id']; ?>"><?php echo $country[$i]['printable_name']; ?></option>
<?php } ?>
</select>
--------------------------------------------------------------------
iso_countries iso_counties
id-------------------------+ id
iso +-----------country_id
printable_name abbrev
iso3 name
numcode
and the url for the javascript code i was trying to use is here
http://www.dynamicdrive.com/dynamicinde ... /index.htm