Skip to [1] [2] [3] [4] [Full screen preview]
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); }
2. [Code][HTML] Code Skip to [1] [2] [3] [4] [Full screen preview]
<select name="province" id="province" onchange="loadRegion('province',2,'city','{:U('Index/getRegion')}');"> <option value="0" selected>省份/直辖市</option><volist name="province" id="vo"> <option value="{$vo.id}" >{$vo.name}</option></volist> </select> <select name="city" id="city" onchange="loadRegion('city',3,'town','{:U('Index/getRegion')}');"> <option value="0">市/县</option> </select> <select name="town" id="town"> <option value="0">镇/区</option> </select>
3. [Code][JavaScript]Code Jump to [1] [2] [3] [4] [Full screen preview]
function loadRegion(sel,type_id,selName,url){ jQuery("#"+selName+" option").each(function(){ jQuery(this).remove(); }); jQuery("<option value=0>请选择</option>").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("<option value="+item.id+">"+item.name+"</option>").appendTo(jQuery("#"+selName)); }); }else{ jQuery("<option value='0'>请选择</option>").appendTo(jQuery("#"+selName)); } } ); } </script>
4. [Code][SQL]Code Jump to [1] [2] [ 3] [4] [Full screen preview]
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;
5. [File] TP_tree.sql ~ 215KB Download (7) [Full screen preview]

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Dreamweaver CS6
Visual web development tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment
