黑马程序员技术交流社区
标题:
【成都校区】 省市联动
[打印本页]
作者:
江山美人
时间:
2019-5-22 17:31
标题:
【成都校区】 省市联动
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>省市联动</title>
<script>
var arrs = new Array(5);
arrs[0] = new Array("杭州市","绍兴市","温州市","义乌市","嘉兴市");
arrs[1] = new Array("南京市","苏州市","扬州市","无锡市");
arrs[2] = new Array("武汉市","襄阳市","荆州市","宜昌市","恩施");
arrs[3] = new Array("石家庄市","唐山市","保定市","邢台市","廊坊市");
arrs[4] = new Array("南充市","达州市","雅安市","宜宾市");
function province(province) {
var p = province.value;
var e = document.getElementById("city");
e.innerHTML="<option>请选择</option>"
for(i=0;i<arrs[p].length;i++){
e.innerHTML+="<option>"+arrs[p][i]+"</option>";
}
}
</script>
</head>
<body>
省份<select id="province" name="province" onchange="province(this)">
<option value="">请选择</option>
<option value="0">浙江</option>
<option value="1">江苏</option>
<option value="2">湖北</option>
<option value="3">河北</option>
<option value="4">四川</option>
</select>
城市<select id="city" name="city">
<option>请选择</option>
</select>
</select>
县区<select id="xq" name="xq">
<option>请选择</option>
</select>
</body>
</html>
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2