I create dropdow list like:
1)db_ajax.sql
# phpMyAdmin MySQL-Dump
# version 2.3.2
# http://www.phpmyadmin.net/ (download page)
#
# Host: localhost
# Generation Time: Aug 14, 2006 at 09:14 PM
# Server version: 4.00.00
# PHP Version: 4.2.3
# Database : `db_ajax`
# --------------------------------------------------------
#
# Table structure for table `city`
#
CREATE TABLE city (
id tinyint(4) NOT NULL auto_increment,
city varchar(50) default NULL,
countryid tinyint(4) default NULL,
PRIMARY KEY (id)
) TYPE=MyISAM;
#
# Dumping data for table `city`
#
INSERT INTO city VALUES (1, 'Los Angales', 1);
INSERT INTO city VALUES (2, 'New York', 1);
INSERT INTO city VALUES (3, 'Toranto', 2);
INSERT INTO city VALUES (4, 'Vancovour', 2);
# --------------------------------------------------------
#
# Table structure for table `country`
#
CREATE TABLE country (
id tinyint(4) NOT NULL auto_increment,
country varchar(20) NOT NULL default '',
PRIMARY KEY (id)
) TYPE=MyISAM;
#
# Dumping data for table `country`
#
INSERT INTO country VALUES (1, 'USA');
INSERT INTO country VALUES (2, 'Canada');
[B]2) findcity.php[/B]
<?
#### Roshan's Ajax dropdown code with php
#### Copyright reserved to Roshan Bhattarai - [email]nepaliboy007@yahoo.com[/email]
#### if you have any problem contact me at http://roshanbh.com.np
#### fell free to visit my blog http://php-ajax-guru.blogspot.com
?>
<? $country=$_REQUEST['country'];
$link = mysql_connect('localhost', 'root', ''); //changet the configuration in required
if (!$link) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db('db_ajax');
$query="select city from city where countryid=$country";
$result=mysql_query($query);
?>
<select name="city">
<option>Select City</option>
<? while($row=mysql_fetch_array($result)) { ?>
<option value><?=$row['city']?></option>
<? } ?>
</select>
[B]3) index.php[/B]
<html>
<head>
<title>Roshan's Ajax dropdown code</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<?
#### Roshan's Ajax dropdown code with php
#### Copyright reserved to Roshan Bhattarai - [email]nepaliboy007@yahoo.com[/email]
#### if you have any problem contact me at http://roshanbh.com.np
#### fell free to visit my blog http://php-ajax-guru.blogspot.com
?>
<script>
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 getCity(strURL) {
var req = getXMLHTTP();
if (req) {
req.onreadystatechange = function() {
if (req.readyState == 4) {
// only if "OK"
if (req.status == 200) {
document.getElementById('citydiv').innerHTML=req.responseText;
} else {
alert("There was a problem while using XMLHTTP:\
" + req.statusText);
}
}
}
req.open("GET", strURL, true);
req.send(null);
}
}
</script>
</head>
<body>
<form method="post" action="" name="form1">
<table width="60%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="150">Country</td>
<td width="150"><select name="country" onChange="getCity('findcity.php?country='+this.value)">
<option value="">Select Country</option>
<option value="1">USA</option>
<option value="2">Canada</option>
</select></td>
</tr>
<tr style="">
<td>City</td>
<td ><div id="citydiv"><select name="city">
<option>Select City</option>
</select></div></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
</table>
</form>
</body>
</html>
==========
But when I sellect Country , city don’t sellect automatic
HELP ME