Let's say I have a table called "address" with a list of addresses in it. Fields include address, city, state.
My HTML form will be a select statement by which the options are populated with the list of distinct states (SELECT DISTINCT state FROM address).
Got that part.
Now I want it to pull a distinct select/option list using the state I just chose in the previous select/option. Seems JavaScript is the way to do this, but I'm pretty rusty at that. I want to return a list of all cities in the table that match the state I just chose.
Ideas? Sample here:
<form action="search.php" method="post" name="resform" id="resform">
State:<select name="state" id="state">
<option value="" selected="selected">Select a State</option>
<?php
$stquery = "SELECT DISTINCT state FROM address";
$stres = mysql_query($stquery) or die(mysql_error());
while ($strow = mysql_fetch_assoc($stres))
{
extract($strow);
echo "<option value=\"" . $state . "\">" . $state . "</option>";
}
?>
</select>
<BR>
<select name="city" id="city">
<!--OPTIONS NEED TO FILL HERE FROM DB -->
</select>