Hi to all,
I have two listboxes, one is state and another is city. As user changes the state, the value of city listbox w.r.t state shuld changed. I do it with using, but I want to do it when user make a selction from state listbox.
//two-list.php
<?php
$con=mysql_connect("localhost","root","");
$db=mysql_select_db('admin');
$state=$_POST['state'];
$city=$_POST['city'];
$submit=$_POST['submit'];
if(!empty($submit))
{
echo "State selected by you :".$state;
echo "<br/>";
echo "State selected by you :".$city;
echo "<br/>";
echo "<br/>";
$insert=mysql_query("insert into state(state,city) values('$state','$city')");
}
?>
<body>
<form action="two-list.php" method="post" enctype="multipart/form-data">
<table width="516" align="center">
<tr><td width="99" valign="top">
List One :
</td><td width="217" valign="top">
<select name="state" size="1" id="state">
<option value="maharashtra">Maharashtra</option>
<option value="delhi">Delhi</option>
<option value="gujrat">Gujrat</option>
<option value="up">UP</option>
</select>
</td>
<td width="84" valign="top">
List Two :</td>
<td width="96">
<?php
if($state=='maharashtra')
{
?>
<p>Welcome to Maharashtra</p>
<select size="1" multiple="multiple">
<option>mumbai</option>
<option>pune</option>
<option>nasik</option>
<option>dhule</option>
</select>
<?php
}
elseif($state=='delhi')
{
?>
<p>Welcome to Delhi</p>
<select size="1" multiple="multiple">
<option>Agra</option>
<option>Raibareli</option>
<option>City1</option>
<option>City2</option>
</select>
<?php
}
elseif($state=='gujrat')
{
?>
<p>Welcome to Gujrat</p>
<select size="1" multiple="multiple">
<option>Surat</option>
<option>Bhuj</option>
<option>Ahemadabad</option>
<option>City2</option>
</select>
<?php
}
else
{
?>
<p>Welcome to Up</p>
<select multiple="multiple">
<option>Bihar</option>
<option>Ratlam</option>
<option>Indore</option>
<option>City2</option>
</select>
<?php
} ?>
</td>
</tr>
<tr><td colspan="7" align="center"><input name="submit" type="submit" id="submit" value="submit" /></td></tr>
</table>
</form>
</body>
How should I do it?