How I can write down a code which uses two Two AJAX-es in combo-boxes?
For Country, when user clicks Country combo-box, State Combo-box will fetch with respective Country, and if when user clicks State combo-box, cities Combo-box will fetch with respective State. All data will came from database. I successfully populate for the Country but not for State

Edited by abhi10kumar: Not full info.

7 Years
Discussion Span
Last Post by happytogether

try to use jQuery

$("#id of of box when you click will do this function").click(function(){
$.get('getcountry.php', function(data) {
	$('# id of your box where you want to display the result').html(data);

in youre getcountry.php

$getCountry = mysql_query("select Name from Country");
		$gco = '<option value="">Select Country </option>';
		while($CountryName = mysql_fetch_array($getCountry)){
		$gco .='<option value="'.$CountryName['Name'].'">'.$CountryName['Name'].'</option>';
	echo $gco;

Edited by Ezzaral: Added code tags. Please use them to format any code that you post.

<select name="country" id="country"></select>
<select name="state" id="state"></select>
<select name="cities" id="cities"></select>

	$.get('getstate.php', function(data) {

	$.get('getcities.php', function(data) {


$getstate = mysql_query("select state from table where country='".$_POST['country']."'");
		while($StateName = mysql_fetch_array($getstate)){
		echo '<option value="'.$StateName['state'].'">'.$StateName['state'].'</option>';


$getcities = mysql_query("select cities from table where state='".$_POST['state']."'");
		while($CitiesName = mysql_fetch_array($getcities)){
		echo '<option value="'.$CitiesName['cities'].'">'.$CitiesName['cities'].'</option>';

and dont forget to download http://code.jquery.com/jquery-1.5.1.min.js

Edited by Ezzaral: Added code tags. Please use them to format any code that you post.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.