when dropdown "selTara" changes the dropdown "selJudet" is loaded with cityes that belong to the appropriate state selected in "selTara".
Example : If i choose France in dropdown 1, in dropdown 2 will appear Paris, Lyon, etc.
So far so good.
What i need is for dropdown 1 to keep the id I choosed. In my script, reloads to the default.
Pls Help.
Here is the script:
Code: Select all
<?php
<?
include("connect_to_db.php");
?>
<table align="center" width="100" cellspacing="0" cellpadding="0" border="1">
<form name="myform" action="test8_1.php" method="post">
<tr>
<td align="center" valign="middle">
<select name="selcountry" onchange="document.forms[0].action='<? $PHP_SELF; ?>'; document.forms[0].submit()">
<option selected value="0">Select country <?php
$sql = "SELECT id_country, country_name FROM country ORDER BY country_name ASC";
$resursa = mysql_query($sql);
while($row = mysql_fetch_array($resursa))
{
print "<option value='".$row['id_country']."'>".$row['country_name']."</option>";
}
?>
</select>
</td>
<td align="center" valign="middle">
<select name="selJudet">
<option selected value="0">Select city
<?php
$sql = "SELECT id_location, location_name FROM location WHERE id_country='".$_POST['selcountry']."'";
$resursa = mysql_query($sql);
while($row = mysql_fetch_array($resursa))
{
print "<option value='".$row['id_location']."'>".$row['location_name']."</option>";
}
?>
</select>
</td>
</tr>
<td align="center" valign="middle"><input type="text" name="something"></td>
</tr>
<input type="submit" name="addToTabel">
</form>
</table>
?>