Copy Code code as follows:
Access to information on national and provincial areas
$ (document). Ready (function () {
Get JSON-formatted data from a program
var info = $request. getattribute ("Manualorderareainfo");
var provinceinfo = $ ("#provinceId");
var Cityid = $ ("#cityId");
Emptying information
Provinceinfo.empty ();
Looping 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 is 1 is the city information
if (Item.parentid = = 1) {
$ ("<option value=" +item.areaid+ ">" +item.areaname+ "</option>"). Appendto (Provinceinfo);
}
});
Get the corresponding 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);
}
});
});
});
Copy Code code as follows:
<tr>
<th style= "width:120px;" > Consignee Province </th>
<!--<td style= "width:270px;" ><input type= "text" value= "$! {manualentryorder.goodreceiverprovince} "name=" Manualentryorder.goodreceiverprovince "style=" width:150px; " Maxlength= "255"/></td>-->
<TD style= "width:270px;" >
<select id= "Provinceid" name= "staffprovince" style= "width:154px"; >
</select>
</td>
<th style= "width:140px;" > Consignee City </th>
<TD style= "width:270px;" >
<!--<input type= "text" value= "$! {manualentryorder.goodreceivercity} "name=" Manualentryorder.goodreceivercity "style=" width:150px; " Maxlength= "255"/>-->
<select id= "Cityid" name= "staffprovince" style= "width:154px"; >
<option value= "--" >---Please select city information---</option>
</select>
</td>
</tr>