省市級聯(lián)
系統(tǒng)
1954 0
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
">
<html xmlns="
http://www.w3.org/1999/xhtml
">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>無標題文檔</title>
<script type="text/javascript" language="javascript">
?var citys = new Array();
?citys["廣東"] = ["汕頭","揭陽","潮州"];
?citys["湖南"] = ["長沙","益陽","張家界"];
?
?function showCitys(){
??//清除市區(qū)下拉列表的選項
??document.getElementById("city").length=0;
??//獲取省份下拉列表選中的值
??var pro = document.getElementById("province").value;
??//將對應的市區(qū)添加到市區(qū)下拉列表
??for(var city in citys[pro]){
???var c = new Option(citys[pro][city],citys[pro][city]);?
???document.getElementById("city").options.add(c);
??}
?}
</script>
</head>
<body>
省:<select id="province" onchange="showCitys();">
??<option value="">請選擇省份</option>
??????? <option value="廣東">廣東</option>
??????? <option value="湖南">湖南</option>
?</select>
??? <br />
市:<select id="city">
??
?</select>
</body>
</html>
省市級聯(lián)
更多文章、技術交流、商務合作、聯(lián)系博主
微信掃碼或搜索:z360901061
微信掃一掃加我為好友
QQ號聯(lián)系: 360901061
您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對您有幫助就好】元