<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="jquery.js"></script>
<title>无标题文档</title>
</head>
<style>
select{ font:12px Arial, Helvetica, sans-serif;padding:2px; background-color:#fff;border:solid 1px #ddd}
</style>
<script type="text/javascript">
function goto(obj){
if(obj.value == "") return;
$.ajax({
type:"GET",
url:"ajax.php?country=" + obj.value,
dateType:'html',
success:function(data){
$(".box").html(data);
$(".city_box").html("");
}
});
}
function get_city(obj){
if(obj.value == "") return;
$.ajax({
type:"GET",
url:"ajax.php?state=" + obj.value,
dateType:'html',
success:function(data){
$(".city_box").html(data);
}
});
}
</script>
<body>
<?
$mysql_host = 'localhost';
$mysql_username = 'root';
$mysql_password = '1320';
$mysql_database = 'test';
$conn= mysql_connect($mysql_host,$mysql_username,$mysql_password);
mysql_select_db($mysql_database,$conn) ;
$ccc = "select * from country";
$aaa = mysql_query($ccc);
?>
<form action="" method="post">
<br />
<br />
<br />
<select id="county" onchange="goto(this)" name="select">
<?
while($row = mysql_fetch_row($aaa)){
?>
<option value="<? echo $row[2];?>"><? echo $row[1];?></option>
<?
}
?>
</select>
<span class="box">
</span>
<span class="city_box">
</span>
<input type="submit" />
</form>
<?
print_r($_POST);
?>
</body>
</html>
国家、州(省)、城市AJAX三级联动
3星 · 超过75%的资源 需积分: 10 57 浏览量
2011-09-21
16:32:50
上传
评论
收藏 2.51MB RAR 举报
喝醉了更拉风
- 粉丝: 1
- 资源: 5
- 1
- 2
- 3
前往页