0

This is my display page

 <label for="City">City</label>
            <div id="city">
            <select id="city"  name="city" onChange="display(this.value)">
            <option value="" selected="selected">-- Select city --</option>
            <?php include("getcitylist.php");?>
            </select>
            </div>

this is my ajax page

    // JavaScript Document
var XMLHttpRequestObject=false;
function display(state_id)
{
if(window.XMLHttpRequest)
{
XMLHttpRequestObject=new XMLHttpRequest();
}
else if(window.ActiveXObject)
{
XMLHttpRequestObject=new ActiveXObject("Microsoft.XMLHTTP");
} 
XMLHttpRequestObject.onreadystatechange=function()
{
if (XMLHttpRequestObject.readyState==4 && XMLHttpRequestObject.status==200)
{
document.getElementById("city").innerHTML=XMLHttpRequestObject.responseText;
}
}
XMLHttpRequestObject.open("GET","getcitylist.php?state_id="+state_id,true);
XMLHttpRequestObject.send();
}

This is my connection page

<?php
include("config.php");


$state_id=$_REQUEST['state_id'];


$query='SELECT tbl_city.*
FROM tbl_city
WHERE tbl_city.state_id ='';
echo $query;


?>

 <select id="city"  name="city" onChange="display(this.value)">
 <option value="" selected="selected">-- Select city --</option>
<?php

$query_result=mysql_query($query)or mysql_error();
while($row=mysql_fetch_array($query_result))
{
?>
<option value="<?php echo $row['id']; ?>"><?php echo $row['city_name']; ?></option>
<?php
}
?>

In the select query what should i display.In table city and table states I want to display city name taking state_id as common from both tables

2
Contributors
1
Reply
9
Views
3 Years
Discussion Span
Last Post by diafol
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.