Phpajax achieves three levels of provincial/municipal linkage
2.
[Code][PHP] code
Jump
public function getdiqudaima(){$rs = $this->db->table('diqudaima') ->field("province,city,zonename,zonecode") ->where("areaid=1 ") ->getAll();$this->db->lastSql();return $rs;}public function getq($code,$n){$where = "and zonecode like '$code%'";$rs = $this->db->table('diqudaima') ->field("province,city,zonename,zonecode") ->where("areaid = $n ".$where) ->getAll();return $rs;}
3.
[Code][PHP] code
Jump
public function showdiqu(){$test = load_model('Test');$data = $test->getdiqudaima();$this->output->set('data',$data);$this->output->display('test.html');}public function showcity(){$test = load_model('Test');$code = $this->input->getTrim('code');$datacity = $test->getq($code,2);echo json_encode($datacity);}public function showqu(){$test = load_model('Test');$code = $this->input->getTrim('code');$datacity = $test->getq($code,3);echo json_encode($datacity);}
4.
[Code][PHP] code
Jump
Select city "); for (var p in obj) {$ (" # city "). append ("" + obj [p]. zonename + "") ;}}) ;}function getq () {var a =$ ("# pro "). val (); $. post ("? C = Test & a = showqu ", {code: a}, function (data) {var obj = eval ('+ data + ')'); $ ("# zone "). empty (); $ ("# zone "). prepend ("Select a zone"); for (var p in obj) {$ ("# zone "). append ("" + obj [p]. zonename + "") ;}}) ;}" _ ue_custom_node _ = "true">