[eluser]tariq123[/eluser]
thanks a lot. I have another script which is working fine but when i post data state value is empty.I have implement this code in this way.First i include javascript in my head section.
[removed]
function getXMLHTTP() { //fuction to return the xml http object
var xmlhttp=false;
try{
xmlhttp=new XMLHttpRequest();
}
catch(e) {
try{
xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e){
try{
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e1){
xmlhttp=false;
}
}
}
return xmlhttp;
}
function getState(countryId) {
var strURL="findState.php?country="+countryId;
var req = getXMLHTTP();
if (req) {
req.onreadystatechange = function() {
if (req.readyState == 4) {
// only if "OK"
if (req.status == 200) {
document.getElementById('statediv')[removed]=req.responseText;
} else {
alert("There was a problem while using XMLHTTP:\n" + req.statusText);
}
}
}
req.open("GET", strURL, true);
req.send(null);
}
}
function getCity(countryId,stateId) {
var strURL="findCity.php?country="+countryId+"&state;="+stateId;
var req = getXMLHTTP();
if (req) {
req.onreadystatechange = function() {
if (req.readyState == 4) {
// only if "OK"
if (req.status == 200) {
document.getElementById('citydiv')[removed]=req.responseText;
} else {
alert("There was a problem while using XMLHTTP:\n" + req.statusText);
}
}
}
req.open("GET", strURL, true);
req.send(null);
}
}
[removed]
then in view file i write this code
<tr>
<td bgcolor="#f3f3f3">Country:</td>
<td bgcolor="#f3f3f3">
<select name="rest_country">
<option value="">Select Country</option>
<option value="1">USA</option>
<option value="2">Canada</option>
</select> </td>
</tr>
<tr>
<td>State:</td>
<td><select name="state">
<option>Select Country First</option>
</select></td>
</tr>
This is file from which i get respone
$query="SELECT id,statename FROM state WHERE countryid='$country'";
$result=mysql_query($query);
?>
<select name="rest_state">
<option>Select State</option>
<? while($row=mysql_fetch_array($result)) { ?>
<option value=<?=$row['id']?>><?=$row['statename']?></option>
<? } ?>
</select>
My ajax request works fine but when i post my data.My state drop down field show empty data.
Please help me to sort out my problem or is there any other solution.