Author Topic: Problem with PhP MySql Ajax dropdown script  (Read 680 times)

0 Members and 1 Guest are viewing this topic.

Offline StefanRSATopic starter

  • Enthusiast
  • Posts: 230
    • View Profile
Problem with PhP MySql Ajax dropdown script
« on: July 02, 2009, 06:11:36 PM »
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 with FireFox, its not working...??? Its working fine in IE.

Can anybody please help me with this problem?

The Form where the dropdown is:
Code: [Select]
<!-- 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
Code: [Select]
<? $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:
Code: [Select]
$province = trim($_POST['province']);
$city = trim($_POST['city']);

In IE $province and $city gets posted
In FF only $province gets posted
If I ask a question, its because I am learning and REALLY tried my best to do it myself but cannot get it to work... If I give an answer, its because I learned about it in the past...