thinkphp 三级联动
2014-05-20 18:47
197 查看
数据库在这里下载 数据库三级联动jquery代码
$(function(){ var html1="<option value='请选择'>请选择</option>"; $("#select2").append(html1); $("#select3").append(html1); $('#select1').change(function(){ var pid=$('#select1').val(); $.getJSON("__URL__/sheng",{pid:pid}, function(json){ $("#select2").empty(); $("#select3").empty(); $("#select2").append(html1); $("#select3").append(html1); $.each(json, function(i,item) { var html=""; html+="<option value="+item.cityID+">"+item.city+"</option>"; $("#select2").append(html); }); }); }); $('#select2').change(function(){ var pid2=$('#select2').val(); $.getJSON("__URL__/shi",{pid2:pid2}, function(json){ $("#select3").empty(); $("#select3").append(html1); $.each(json, function(i,item) { var html=""; html+="<option value="+item.areaID+">"+item.area+"</option>"; $("#select3").append(html); }); }); }); });html代码
<form name="myform" action="" method="post"> 省份: <select id="select1" name="select1"> <option value='请选择'>请选择</option> <volist name="list" id="vo"> <option value="{$vo.provinceID}" id="{$vo.provinceID}"> {$vo.province} </option> </volist> </select> 市: <select id="select2" name="select2"> </select> 县: <select id="select3" name="select3"> </select> </form>控制器代码
public function index(){ $administrator= D('province'); $list=$administrator->select(); $this->assign('list',$list); $this->display(); } public function sheng(){ $city= D('city'); $pid=$_REQUEST['pid']; $where['father']=$pid; $data=$city->where($where)->select(); echo json_encode($data); } public function shi(){ $city= D('area'); $pid=$_REQUEST['pid2']; $where['father']=$pid; $data=$city->where($where)->select(); echo json_encode($data); }
相关文章推荐
- Thinkphp实现省市区三级联动
- 继上一篇的thinkphp三级联动数据库
- ThinkPHP利用Ajax实现省市县地区三级联动
- thinkphp 省市区三级联动
- Thinkphp实现省市区三级联动
- thinkphp下的三级联动(带有缓存的)
- ThinkPhP。 异步实现地区三级联动
- Thinkphp dwz 三级联动下拉菜单
- thinkphp5 三级联动
- 基于thinkphp和ajax的省市区三级联动
- ThinkPHP+AJAX三级联动
- 基于ThinkPHP+AJAX的省市区三级联动
- ThinkPHP三级联动回显
- Thinkphp dwz 三级联动下拉菜单
- thinkPHP实现的省市区三级联动功能示例
- ThinkPHP快速简单实现Ajax地区三级联动(很详细)
- 基于ThinkPHP+AJAX的省市区三级联动
- 在thinkphp中使用省市县三级菜单联动
- 做个简单的thinkphp三级联动
- 页面三级联动操作