検索
ホームページphp教程PHP源码php ajax 实现三级省市区联动

                         

           

2. [代码][PHP]代码     跳至                               

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. [代码][PHP]代码     跳至                               

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. [代码][PHP]代码     跳至                               

请选择市"); 		
				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("请选择区"); 		
				for(var p in obj){
					$("#zone").append(""+obj[p].zonename+"");
				    
				}
			}
		);
	}
" _ue_custom_node_="true">

声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。

ホットAIツール

Undresser.AI Undress

Undresser.AI Undress

リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover

AI Clothes Remover

写真から衣服を削除するオンライン AI ツール。

Undress AI Tool

Undress AI Tool

脱衣画像を無料で

Clothoff.io

Clothoff.io

AI衣類リムーバー

AI Hentai Generator

AI Hentai Generator

AIヘンタイを無料で生成します。

ホットツール

AtomエディタMac版ダウンロード

AtomエディタMac版ダウンロード

最も人気のあるオープンソースエディター

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Eclipse を SAP NetWeaver アプリケーション サーバーと統合します。

ゼンドスタジオ 13.0.1

ゼンドスタジオ 13.0.1

強力な PHP 統合開発環境

VSCode Windows 64 ビットのダウンロード

VSCode Windows 64 ビットのダウンロード

Microsoft によって発売された無料で強力な IDE エディター

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

強力な PHP 統合開発環境