<html>
<head>
<title>下拉列表</title>
<script language="JavaScript">
function changeCity(){
var cityList = new Array();
cityList[0] = ['常州','淮安','连云港','南京','南通','苏州','宿迁','泰州','无锡','徐州','盐城','扬州','镇江'];
cityList[1] = ['合肥市','芜湖市','蚌埠市','淮南市','马鞍山市','淮北市','铜陵市','安庆市','黄山市','阜阳市','宿州市','滁州市','六安市','宣城市','池州市','亳州市'];
cityList[2] = ['济南','青岛','淄博','枣庄','东营','烟台','潍坊','济宁','泰安','威海','日照','莱芜','临沂','德州','聊城','滨州','菏泽'];
var pIndex = document.selform.selProvince.selectedIndex-1;
var i=document.selform.selCity.options.length;
if(i>1){
for(var h=0;h<i;h++){
document.selform.selCity.options.remove(1);
}
}
//document.selform.selCity.options.remove(i);
for(var j in cityList[pIndex]){
var optionAdd = new Option(cityList[pIndex][j],cityList[pIndex][j]);
document.selform.selCity.options.add(optionAdd);
}
}
</script>
</head>
<body>
<form name="selform">
<select οnchange="changeCity()" name="selProvince">
<option >----省份----</option>
<option >江苏省</option>
<option >安徽省</option>
<option >山东省</option>
</select>
<br>
<select name="selCity">
<option>----城市----</option>
</select>
</form>
</body>
</html>
<head>
<title>下拉列表</title>
<script language="JavaScript">
function changeCity(){
var cityList = new Array();
cityList[0] = ['常州','淮安','连云港','南京','南通','苏州','宿迁','泰州','无锡','徐州','盐城','扬州','镇江'];
cityList[1] = ['合肥市','芜湖市','蚌埠市','淮南市','马鞍山市','淮北市','铜陵市','安庆市','黄山市','阜阳市','宿州市','滁州市','六安市','宣城市','池州市','亳州市'];
cityList[2] = ['济南','青岛','淄博','枣庄','东营','烟台','潍坊','济宁','泰安','威海','日照','莱芜','临沂','德州','聊城','滨州','菏泽'];
var pIndex = document.selform.selProvince.selectedIndex-1;
var i=document.selform.selCity.options.length;
if(i>1){
for(var h=0;h<i;h++){
document.selform.selCity.options.remove(1);
}
}
//document.selform.selCity.options.remove(i);
for(var j in cityList[pIndex]){
var optionAdd = new Option(cityList[pIndex][j],cityList[pIndex][j]);
document.selform.selCity.options.add(optionAdd);
}
}
</script>
</head>
<body>
<form name="selform">
<select οnchange="changeCity()" name="selProvince">
<option >----省份----</option>
<option >江苏省</option>
<option >安徽省</option>
<option >山东省</option>
</select>
<br>
<select name="selCity">
<option>----城市----</option>
</select>
</form>
</body>
</html>