码迷,mamicode.com
首页 > 其他好文 > 详细

tp三级联动

时间:2015-05-09 10:10:48      阅读:133      评论:0      收藏:0      [点我收藏+]

标签:

<script type="text/javascript">
$(document).ready(function(){
  $("#province").change(function(){
  var value=$("#province").val();
  //alert (value);
  htmlobj=$.ajax({url:"__PUBLIC__/php/city.php",async:false,data:
{value:value}});
  $("#city").html(htmlobj.responseText);
});
}); 

$(document).ready(function(){
  $("#city").change(function(){
  var value=$("#city").val();
  //alert (value);
  htmlobj=$.ajax({url:"__PUBLIC__/php/district.php",async:false,data:
{value:value}});
  $("#district").html(htmlobj.responseText);
});
});
</script>

 

city
district

 


<?php
header("Content-type: text/html; charset= utf-8");
$con = mysql_connect("localhost","root","root");
if (!$con)
{
die(‘Could not connect: ‘ . mysql_error());
}
mysql_query("SET NAMES ‘UTF8‘");
mysql_select_db("hn", $con);
$result = mysql_query("SELECT * FROM xp_sys_city where ProvinceID = ".$_GET[‘value‘]);
while($row = mysql_fetch_array($result))
{
echo "<option value=‘".$row[‘ID‘]."‘>".$row[‘CityName‘]."</option>";
}

 

 

 

 

 

 

<script src="__PUBLIC__/bower_components/jquery/city_ajax.js"></script>

city
district

 

tp三级联动

标签:

原文地址:http://www.cnblogs.com/hellowzd/p/4489432.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!