The corresponding implementation of provinces and cities:< still some not packaged up >
More selective provinces to determine the content of the city
JSP Code:
Copy Code code as follows:
<body>
Province <select name= "Prin" >
<option>--Please select--</option>
<option> Fujian </option>
<option> Beijing </option>
<option> Shandong </option>
<option> Shanghai </option>
</select>
County, city <select id= "Sel2" >
<option>--Please select--</option>
</select>
</body>
JS Code:
Copy Code code as follows:
function Appendshi (shi) {//string concatenation, stitching downtown
var fjs= ';
for (Var i=0;i<shi.length;i++)
{
Fjs + = ' <option> ' + shi[i]+ ' </option> ';
}
return FJS;
}
$ (function () {
var Prince = [' Fujian ', ' Beijing ', ' Shandong ', ' Shanghai '];
var fjs = [' Xiamen ', ' Quanzhou ', ' Fuzhou '];
var bjs = [' Beijing ', ' Chaoyang District ', ' Haidian ', ' Pinggu District '];
var SHS = [' Huangpu ', ' Changning district ', ' Baoshan ', ' Jiading '];
var SDS = [' Jinan ', ' Qingdao ', ' Yantai ', ' Rizhao ', ' Laiwu ', ' SSS '];
$ ("Select[name= ' Prin ']"). Change (function () {
var Shi = $ ("#sel2");//Get a second Select
var prin = $ ("select[name= ' Prin '][select option:selected]")//The value of the selected identity
var Newshisel = $ (' <select id= ' sel2 ' ><option>--Please select--</option></select> ');
if (prin.val () = = ' Fujian ') {
Newshisel.append (Appendshi (FJS));
}
if (prin.val () = = ' Beijing ') {
Newshisel.append (Appendshi (BJS));
}
if (prin.val () = = ' Shanghai ') {
Newshisel.append (Appendshi (SHS));
}
if (prin.val () = = ' Shandong ') {
Newshisel.append (Appendshi (SDS));
}
Shi.replacewith (Newshisel);
});
});