您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

Thinkphp实现省市区三级联动

2024/2/17 21:23:55发布28次查看
一张表实现省市区三级联动【3409条数据】
public function index(){ $province = m('tree')->where ( array('pid'=>1) )->select (); $this->assign('province',$province); $this->display(); } public function getregion(){ $region=m(tree); $map['pid']=$_request[pid]; $map['type']=$_request[type]; $list=$region->where($map)->select(); echo json_encode($list); }
省份/直辖市 {$vo.name} 市/县 镇/区
function loadregion(sel,type_id,selname,url){ jquery(#+selname+ option).each(function(){ jquery(this).remove(); }); jquery(请选择).appendto(jquery(#+selname)); if(jquery(#+sel).val()==0){ return; } jquery.getjson(url,{pid:jquery(#+sel).val(),type:type_id}, function(data){ if(data){ jquery.each(data,function(idx,item){ jquery(+item.name+).appendto(jquery(#+selname)); }); }else{ jquery(请选择).appendto(jquery(#+selname)); } } ); }
drop table if exists `tp_tree`; create table `tp_tree` ( `id` int(5) unsigned not null auto_increment, `pid` int(5) unsigned not null default '0', `name` varchar(120) default null, `type` tinyint(1) default '2', primary key (`id`) ) engine=myisam auto_increment=3410 default charset=utf8;
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product