HI, I am using Roshan's Ajax dropdown code for my two ajax dropdown menus.

All is working fine, but when I want to use $_POST in the submitted form in FireFox, its not working...??? Its working fine in IE.

Can anybody please help me with this problem?

The Form where the dropdown is:

<!-- Province goes here -->
<tr>
	<td>-</td><td>-</td><td>-</td><td>-</td><td>Province</td><td>
  <select name="province" onChange="getCity('../dir/townsrc.php?province='+this.value)">
  <option value="">Select Province</option>
  <option value="1">KwaZulu-Natal</option>
  <option value="2">Western Cape</option>
  <option value="3">Eastern Cape</option>
  <option value="4">Free State</option>
  <option value="5">Gauteng</option>
  <option value="6">Limpopo</option>
  <option value="7">Mpumalanga</option>
  <option value="8">North West</option>
  <option value="9">Northern Cape</option>
  </select>
</td>
</tr>
<!-- Province ends here -->
<!-- Town goes here -->
<tr>
	<td>-</td><td>-</td><td>-</td><td>-</td><td>Town</td><td>
  <div id="citydiv"><select name="city">
 <option>Select Town</option>
     </select>
 </div>

  </td>
</tr>
<!-- Town ends here -->

The townsrc.php:

<? $country=intval($_GET['province']);

$query=("SELECT * FROM search_town 
WHERE provId=$country
ORDER BY townLabel ASC");
$result=mysql_query($query);

?>
<select name="city">
<option>Select Town</option>
<? while($row=mysql_fetch_array($result)) { ?>
<option value><?=$row['townLabel']?></option>
<? } ?>
</select>

The submit for:

$province = trim($_POST['province']);
$city = trim($_POST['city']);

In IE $province and $city gets posted
In FF only $province gets posted

Hi there,
Nothing leaps out at me as being wrong with your code, except it being a little incomplete. Eg your php side AJAX file doesn't echo the output or give any of the option elements any values. You could try this: Instead of replacing the entire select element with your ajax call, only replace the <option> elements. Ie, put the "cityDiv" tags inside the select tags and dont return the select tags with the ajax.

Good luck

P.S Forgot to mention South Africa is the BEST. (Not really, just Jo'burg and Pretoria, but you don't meet too many South Africans in the online community)

hi
i think you need to add id for the all select tag

<select name="city" id="city">

I hope this solve your problem
Thanks

This article has been dead for over six months. Start a new discussion instead.