Get information about the provinces and cities of China
$ (document). Ready (function () {
Get JSON-formatted data from a program
var info = $request. getattribute ("Manualorderareainfo");
var provinceinfo = $ ("#provinceId");
var Cityid = $ ("#cityId");
Clear information
Provinceinfo.empty ();
Loop to get information
$.each (Info.area, function (Idx,item) {
if (idx = = 0) {
return true;
}
Alert ("Name:" +idx+ ", Areaid:" +item.areaid+ ", AreaName:" +item.areaname+ ", Areaparentid:" +item.parentid ");
Here the parent class ID 1 is the city information
if (Item.parentid = = 1) {
$ ("<option value=" +item.areaid+ ">" +item.areaname+ "</option>"). AppendTo (Provinceinfo);
}
});
Get the city information
$ ("#provinceId"). Change (function () {
var tempinfo = $ ("#provinceId"). Val ();
Cityid.empty ();
$.each (Info.area, function (Indexinfo,item) {
if (Indexinfo = = 0) {
return true;
}
if (Item.parentid = = Tempinfo) {
$ ("<option value=" +item.areaid+ ">" +item.areaname+ "</option>"). AppendTo (Cityid);
}
});
});
});
Java JSON provincial cascade