Home > Backend Development > PHP Tutorial > Thinkphp dwz 三级联动上拉菜单

Thinkphp dwz 三级联动上拉菜单

WBOY
Release: 2016-06-13 13:05:24
Original
855 people have browsed it

Thinkphp dwz 三级联动下拉菜单

Tpl\ComBox\index.html:

<h2 class="contentTitle">下拉菜单</h2>

<div class="pageContent" layoutH="56">
	<select class="combox" name="province" ref="w_combox_city" refUrl="__URL__/returnCity/cityId/{value}">
		<option value="all">所有省市</option>
		<option value="bj">北京</option>
		<option value="sh">上海</option>
	</select>
	<select class="combox" name="city" id="w_combox_city" ref="w_combox_area" refUrl="__URL__/returnArea/areaId/{value}">
		<option value="all">所有城市</option>
	</select>
	<select class="combox" name="area" id="w_combox_area">
		<option value="all">所有区县</option>
	</select>
</div>
Copy after login


Action\ComBoxAction.class.php:

<?php
// 三级联动下拉菜单
class ComBoxAction extends CommonAction {    
     
    public function returnCity(){
        $cityId = $_REQUEST['cityId'];
        if($cityId=='sh'){
            $arrCity = array(array('all','所有城市'),array('sh','上海市'));
        }else if($cityId=='bj'){
            $arrCity = array(array('all','所有城市'),array('bj','北京市'));
        }else{
            $arrCity = array(array('all','所有城市'));
        }
         echo json_encode($arrCity);
    }
    
    public function returnArea(){
        $areaId = $_REQUEST['areaId'];
        if($areaId=='sh'){
            $arrArea = array(array('1','上海城市1'),array('2','上海城市2'));
        }else if($areaId=='bj'){
            $arrArea = array(array('3','北京城市3'),array('bj','北京城市4'));
        }else{
            $arrArea = array(array('all','所有城市'));
        }
        
         echo json_encode($arrArea);
    }
    
}
?>
Copy after login


 

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template