Hi all,
Please find the code, where I have problem. The country selected is to be used for displaying state list. Also when the form is seen, the list of states of default country in the country list box is to be displayed.
Can anybody help me out in ths code? How to update this state list thorugh "onchange" ? Am I going on right track or what is to be changed?
<script>
function ChangeNames(x)
{
$current_number_found = x ;
alert ($current_number_found) ;
}
</script>
<table border="1" width="740" cellspacing="0" bgcolor="#FFE6D9" align="CENTER" bordercolor="FFD8B0">
<tr>
<td width="200" align="middle" valign="middle" bgcolor="#FFF3EF"
class="text">Country :<br>
</td>
<td width="540" align="middle" bgcolor="#FFF3EF">
<SELECT NAME="country_array" onChange="ChangeNames(this.options.selectedIndex)">
<?php
/ Build the list of countries here, so that it can be displayed in the list-box. /
$query = " SELECT country_id, country_description
FROM country_m
Order by country_description " ;
$country_result = mysql_query($query) or die ("SELECT not proper.");
/ Now, append country_id's below the NULL value. /
while ($list = mysql_fetch_array($country_result))
{
?>
<OPTION value=<?php echo $list[country_id] ; ?> >
<?php echo $list[country_description] ; ?>
</OPTION>
<?php } ?>
</SELECT>
</td>
</tr>
</table>
<table border="1" width="740" cellspacing="0" bgcolor="#FFE6D9" cellpadding="0" align="CENTER" bordercolor="#FFD8B0">
<tr>
<td width="330" align="middle" height="28" valign="middle" bgcolor="#FFF3EF" class="text"> Select State :
</td>
<td width="325" align="middle" valign="middle">
<select multiple name="available_list" size=8 style="width:325;" class="engfont">
<?php
/ Build the list of states here, so that it can be displayed in the list-box. /
$query = "select A.state_id, state_description from states_m WHERE A.country_id = <<country_selected_from_list>> order by state_description ";
$state_result = mysql_query($query) or die ("SELECT for states failed.");
while ($list = mysql_fetch_array($state_result))
{
?>
<OPTION value=<?php echo $list[state_id] ; ?> >
<?php echo ltrim($list[state_description]) ; ?>
</OPTION>
<?php } ?>
</select>
</td> </tr> </table>