| | |
Problem with PhP MySql Ajax dropdown code
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jul 2009
Posts: 2
Reputation:
Solved Threads: 0
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:
The townsrc.php:
The submit for:
In IE $province and $city gets posted
In FF only $province gets posted
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:
PHP Syntax (Toggle Plain Text)
<!-- 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:
PHP Syntax (Toggle Plain Text)
<? $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:
PHP Syntax (Toggle Plain Text)
$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
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(); }
if (isset($_COOKIE)){
$me->eat($_COOKIE);
} else { $me->starve(); }
hi
i think you need to add id for the all select tag
I hope this solve your problem
Thanks
i think you need to add id for the all select tag
PHP Syntax (Toggle Plain Text)
<select name="city" id="city">
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"
"Confidence is everything"
![]() |
Similar Threads
- Looking for PHP / MySQL Developer (Web Development Job Offers)
- Looking for a PHP/MYSQL Programmer (Web Development Job Offers)
- Need Highly Experienced PHP/MySQL Programmer $15-$25/hour (Web Development Job Offers)
- Urgent: PHP, MySQL, AJAX Developer (Web Development Job Offers)
- [For Hire] PHP, Mysql, ASP, AJAX, DHTML programer (Post your Resume)
- Online Database - PHP/ MYSQL (PHP)
Other Threads in the PHP Forum
- Previous Thread: About image mirroring using php
- Next Thread: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource
| Thread Tools | Search this Thread |
.htaccess ajax alerts apache api array autocomplete beginner binary broken cakephp checkbox class cms code convert cron curl database date display dynamic echo email emptydisplayvalue error errors explodefunction file files folder form forms function functions google hack href htaccess html htmlspecialchars image include insert integration ip java javascript joomla keywords limit link login loop mail menu methods mlm multiple mysql network object oop paypal pdf php problem query radio random recursion recursive redirect regex remote script search securephp server sessions shot sms soap source space sql subscription syntax system table tutorial update upload url validator variable video web xml youtube





