---restore content starts---
<select id = "a1" onchange = "addoption ()" ></select>
<select id = "A2" ></select>
<script type = "Text/javascript" >
var city = new Array;
city[' Jiangsu '] = [' Nanjing ', ' Shanghai ', ' Lianyungang ', ' Suzhou ', ' Zhenjiang ', ' Taizhou ', ' Nantong ', ' Huaian '];
city[' shandong '] = [' Qingdao ', ' Yantai ', ' Jinan ', ' Qufu ', ' Dezhou ', ' Binzhou ', ' Linyi ', ' Heze '];
city[' hunan '] = [' Changsha ', ' Zhuzhou ', ' Xiangtan ', ' Yueyang ', ' Loudi ', ' Changde ', ' Huaihua ', ' Zhangjiajie '];
function allcity () {
var Select1 = document.getElementById ("A1");
for (var i in city) {//Note here The syntax for iterating over an array
Select1.add (New Option (I, i), null);
}
AddOption (); Initialization options
}
function AddOption () {
var select2 = document.getElementById ("A2");
var Select1 = document.getElementById ("a1"). Value;
select2.length = 0; Clear the city menu every time.
if (select1! = ' Please select Province ') {
for (Var i in City[select1]) {
Select2.add (New Option (City[select1][i], city[select1][i]), NULL);
}
}else if (sheng = = ' Please select Province ') {
select2.length = 0;
Select2.add ("Please select City", "Select City"), null);
}
}
Window.onload = Allcity ();
</script>
---restore content ends---
JavaScript array Two-level linkage drop-down list