<?php header (' Content-type:application/json; Charset=utf-8 ');
Echo ' province=[]; foreach ($arrProvinces as $province) {echo ' Province.push ['. $province [' Provinceid ']. ', '. $province [' Provincename ']
.'"]);';
}
Echo ' city=[]; foreach ($arrCitys as $city) {echo ' City.push ['. $city [' Provinceid ']. $city [' Cityid ']. $city [' CityName ']. '
]);'; }
<script type= "Text/javascript" > Function initprovince () {var Objprov = jQuery (' #locationForm '). Get (
0). province;
objProv.options.length = 0;
for (var i=0 i<province.length; i++) {objprov.options[i] = new Option (province[i][1), province[i][0]);
} function Onprovincechange () {var Objprov = jQuery (' #locationForm '). Get (0). province;
var objcity = jQuery (' #locationForm '). Get (0). City;
Provinceid = Objprov.value;
objCity.options.length = 0;
Objcity.options[0] = new Option (' Please select ', 0); for (var i=1,j=1 i<=city.length; i++) {if (city[i-1][0] = = Provinceid) {objcity.options[j++]
= new Option (city[i-1][2], city[i-1][1]);
}} jQuery (document). Ready (function () {initprovince ();
}); </script>
<form id= "Locationform" >
<select id= "province" onchange= "Onprovincechange ()" ></select>
<select id= "City" ></select>
</form>