Problem with PhP MySql Ajax dropdown code

Reply

Join Date: Jul 2009
Posts: 2
Reputation: StefaRSA is an unknown quantity at this point 
Solved Threads: 0
StefaRSA StefaRSA is offline Offline
Newbie Poster

Problem with PhP MySql Ajax dropdown code

 
0
  #1
Jul 2nd, 2009
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:
  1. <!-- Province goes here -->
  2. <tr>
  3. <td>-</td><td>-</td><td>-</td><td>-</td><td>Province</td><td>
  4. <select name="province" onChange="getCity('../dir/townsrc.php?province='+this.value)">
  5. <option value="">Select Province</option>
  6. <option value="1">KwaZulu-Natal</option>
  7. <option value="2">Western Cape</option>
  8. <option value="3">Eastern Cape</option>
  9. <option value="4">Free State</option>
  10. <option value="5">Gauteng</option>
  11. <option value="6">Limpopo</option>
  12. <option value="7">Mpumalanga</option>
  13. <option value="8">North West</option>
  14. <option value="9">Northern Cape</option>
  15. </select>
  16. </td>
  17. </tr>
  18. <!-- Province ends here -->
  19. <!-- Town goes here -->
  20. <tr>
  21. <td>-</td><td>-</td><td>-</td><td>-</td><td>Town</td><td>
  22. <div id="citydiv"><select name="city">
  23. <option>Select Town</option>
  24. </select>
  25. </div>
  26.  
  27. </td>
  28. </tr>
  29. <!-- Town ends here -->

The townsrc.php:
  1. <? $country=intval($_GET['province']);
  2.  
  3. $query=("SELECT * FROM search_town
  4. WHERE provId=$country
  5. ORDER BY townLabel ASC");
  6. $result=mysql_query($query);
  7.  
  8. ?>
  9. <select name="city">
  10. <option>Select Town</option>
  11. <? while($row=mysql_fetch_array($result)) { ?>
  12. <option value><?=$row['townLabel']?></option>
  13. <? } ?>
  14. </select>

The submit for:
  1. $province = trim($_POST['province']);
  2. $city = trim($_POST['city']);

In IE $province and $city gets posted
In FF only $province gets posted
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 172
Reputation: Menster is an unknown quantity at this point 
Solved Threads: 22
Menster's Avatar
Menster Menster is offline Offline
Junior Poster

Re: Problem with PhP MySql Ajax dropdown code

 
0
  #2
Jul 3rd, 2009
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
$me = new Person();
if (isset($_COOKIE)){
$me->eat($_COOKIE);
} else { $me->starve(); }
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 172
Reputation: Menster is an unknown quantity at this point 
Solved Threads: 22
Menster's Avatar
Menster Menster is offline Offline
Junior Poster

Re: Problem with PhP MySql Ajax dropdown code

 
0
  #3
Jul 3rd, 2009
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)
$me = new Person();
if (isset($_COOKIE)){
$me->eat($_COOKIE);
} else { $me->starve(); }
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 77
Reputation: Tulsa is an unknown quantity at this point 
Solved Threads: 15
Tulsa's Avatar
Tulsa Tulsa is offline Offline
Junior Poster in Training

Re: Problem with PhP MySql Ajax dropdown code

 
0
  #4
Jul 4th, 2009
hi
i think you need to add id for the all select tag
  1. <select name="city" id="city">
I hope this solve your problem
Thanks
Last edited by peter_budo; Jul 6th, 2009 at 6:49 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
"Be honest"
"Confidence is everything"
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC