Drop down menu selection that limits option available in fld
Posted: Wed Oct 07, 2009 9:29 pm
I have a form that I would like users to select their country. If a user selects USA, then I would like my state drop down that also includes Canada provinces to only show US states only as selectable (and vis a vis, if Canada is slected). For all other countries other than USA or Canada, I would like an open text box for entering territories instead of the State/Province drop down. Any ideas how can set this up?
FYI, the options available in my Country and State drop downs are pulled from my mysql table. Here's a sample of the code:
FYI, the options available in my Country and State drop downs are pulled from my mysql table. Here's a sample of the code:
Code: Select all
<?
$optiondropdwnquery = "SELECT optionid, optionname FROM OptionsLib WHERE optiongroupid = 6";
$optionsavailresult = mysql_query($optiondropdwnquery);
$selectedValue = isset($country) ? $country : '';
echo '<select name="country">' . "\n";
while ($row = mysql_fetch_array($optionsavailresult, MYSQL_ASSOC)) {
echo '<option value="' . $row['optionid']. '" ' . ($row['optionid']== $selectedValue ? 'selected="selected"' : '') . '>' . $row['optionname'] . '</option>' . "\n";
}
echo '</select>';
?>