javascript城市select聯動功能表代碼

來源:互聯網
上載者:User
關鍵字 網頁製作 Ajax JavaScript

下面這款網頁特效城市select聯動功能表代碼是我從其它網站搞下來的,很好用的,全部所有城市都用了,你只要把js部份保存,然後修select修改成如下面這個select同名就可以使用了。

<p><select class="select_com" id="city" style="margin-top: -1px; margin-left: -1px; width: 134px; height: 25px" name="city">


<option selected="selected">選擇城市</option>


</select> www.111cn.net</p>


<script>


     var eczones  = new array();


 eczones[0]="北京|北京";


 eczones[1]="上海|上海";


 eczones[2]="天津|天津";


 eczones[3]="重慶|重慶";


 eczones[4]="廣東|廣東";


 eczones[5]="江蘇|江蘇";


 eczones[6]="浙江|浙江";


 eczones[7]="福建|福建";


 eczones[8]="湖南|湖南";


 eczones[9]="湖北|湖北";


 eczones[10]="山東|山東";


 eczones[11]="遼寧|遼寧";


eczones[12]="吉林|吉林";


 eczones[13]="雲南|雲南";


 eczones[14]="四川|四川";


 eczones[15]="安徽|安徽";


 eczones[16]="江西|江西";


 eczones[17]="黑龍江|黑龍江";


 eczones[18]="河北|河北";


 eczones[19]="陝西|陝西";


 eczones[20]="海南|海南";


 eczones[21]="河南|河南";


 eczones[22]="山西|山西";


 eczones[23]="內蒙古|內蒙古";


 eczones[24]="廣西|廣西";


 eczones[25]="貴州|貴州";


 eczones[26]="寧夏|寧夏";


 eczones[27]="青海|青海";


 eczones[28]="新疆|新疆";


 eczones[29]="西藏|西藏";


 eczones[30]="甘肅|甘肅";


 eczones[31]="臺灣|臺灣";


 eczones[32]="香港|香港";


 eczones[33]="澳門|澳門";


 eczones[34]="國外|國外";


eczones[35]="不限|-不限-";


  


function setcity2(thevalue,instance,selectvalue) {


switch (thevalue) {


case '北京':


var labels = new array("北京市");


var values = new array("北京市");


break;


case '天津' :


var labels = new array("天津市");


var values = new array("天津市");


break


case '上海' :


var labels = new array("上海市");


var values = new array("上海市");


break


case '重慶' :


var labels = new array("重慶市");


var values = new array("重慶市");


break


case '湖南' :


var labels = new array("長沙","湘潭","岳陽","株洲","張家界","衡陽","郴州","湘鄉","汨羅","常德","津市","吉首","婁底","漣源","冷水江","懷化","洪江", "益陽","耒陽","邵陽","永州","冷水灘","其他");


var values = new array("長沙","湘潭","岳陽","株洲","張家界","衡陽","郴州","湘鄉","汨羅","常德","津市","吉首","婁底","漣源","冷水江","懷化","洪江","益陽" ,"耒陽","邵陽","永州","冷水灘","其他");


break


case '江蘇' :


var labels = new array("南京","蘇州","無錫","揚州","常州","鎮江","南通","江陰","連雲港","徐州","淮陰","宿遷","東台","泰州","儀征","丹陽","宜興"," 常熟","淮安","鹽城","興化","姜堰","其他");


var values = new array("南京","蘇州","無錫","揚州","常州","鎮江","南通","江陰","連雲港","徐州","淮陰","宿遷","東台","泰州","儀征","丹陽","宜興"," 常熟","淮安","鹽城","興化","姜堰","其他");


break


case '浙江' :


var labels = new array("杭州","寧波","溫州","金華","義烏","紹興","湖州","余姚","臨海","蕭山","臨安","諸暨","嵊泗","紹興縣","蘭溪縣","嘉興","海甯", "桐鄉","衢州","上虞","嵊州","慈溪","麗水","甌海","黃岩","椒江","台州","其他");


var values = new array("杭州","寧波","溫州","金華","義烏","紹興","湖州","余姚","臨海","蕭山","臨安","諸暨","嵊泗","紹興縣","蘭溪縣","嘉興","海甯", "桐鄉","衢州","上虞","嵊州","慈溪","麗水","甌海","黃岩","椒江","台州","其他");


break


case '福建' :


var labels = new array("福州","廈門","泉州","漳州","石獅","三明","南平","莆田","永安","邵武","龍岩","其他");


var values = new array("福州","廈門","泉州","漳州","石獅","三明","南平","莆田","永安","邵武","龍岩","其他");


break


case '廣東' :


var labels = new array("廣州","深圳","東莞","中山","佛山","珠海","惠州","汕頭","湛江","潮州","潮陽","江門","汕尾","茂名","陽江","肇慶","梅州"," 雲浮","清遠","韶關","河源","揭陽","其他"); 


var values = new array("廣州","深圳","東莞","中山","佛山","珠海","惠州","汕頭","湛江","潮州","潮陽","江門","汕尾","茂名","陽江","肇慶","梅州"," 雲浮","清遠","韶關","河源","揭陽","其他");


break


case '湖北' :


var labels = new array("武漢","宜昌","孝感","荊州","襄樊","老河口","枝城","棗陽","荊門","宜城","黃石","鄂州","黃岡","咸甯","武穴","蒲昕","麻城"," 十堰","恩施","丹江口","利川","天門","漢川","洪湖","應城","潛江","安陸","仙桃","隨州","石首","其他");


var values = new array("武漢","宜昌","孝感","荊州","襄樊","老河口","枝城","棗陽","荊門","宜城","黃石","鄂州","黃岡","咸甯","武穴","蒲昕","麻城","十堰", "恩施","丹江口","利川","天門","漢川","洪湖","應城","潛江","安陸","仙桃","隨州","石首","其他");


break


case '山東' :


var labels = new array("濟南","青島","煙臺","淄博","濰坊","臨沂","萊蕪","濟甯","荷澤","日照","藤州","聊城","德州","濱州","臨清","青州","威海"," 泰安","新泰","曲阜","東營","諸城","棗莊","其他");


var values = new array("濟南","青島","煙臺","淄博","濰坊","臨沂","萊蕪","濟甯","荷澤","日照","藤州","聊城","德州","濱州","臨清","青州","威海"," 泰安","新泰","曲阜","東營","諸城","棗莊","其他");


break


case '遼寧' :


var labels = new array("瀋陽","鐵嶺","撫順","大連","本溪","營口","錦州","興城","北票","盤錦","遼陽","鐵法","鞍山","瓦房店","丹東","錦西","朝陽"," 阜新","海城","其他");


var values = new array("瀋陽","鐵嶺","撫順","大連","本溪","營口","錦州","興城","北票","盤錦","遼陽","鐵法","鞍山","瓦房店","丹東","錦西","朝陽"," 阜新","海城","其他");


break


case '吉林' :


var labels = new array("長春","吉林","通化","扶余","樺甸","延吉","圖門","龍井","敦化","集安","渾江","梅河口","四平","公主嶺","遼源","白城","洮南","九台" ,"其他");


var values = new array("長春","吉林","通化","扶余","樺甸","延吉","圖門","龍井","敦化","集安","渾江","梅河口","四平","公主嶺","遼源","白城","洮南", "九台","其他");


break


case '雲南' :


var labels = new array("昆明","曲靖","大理","玉溪","麗江","楚雄","開遠","迪慶","東川","昭通","個舊","保山","文山","其他");


var values = new array("昆明","曲靖","大理","玉溪","麗江","楚雄","開遠","迪慶","東川","昭通","個舊","保山","文山","其他");


break


case '四川' :


var labels = new array("成都","宜賓","瀘州","內江","攀枝花","西昌","德陽","雅安","遂甯","南充","綿陽","廣元","瑪律康","達縣","華鑒","自貢","樂山", "其他");


var values = new array("成都","宜賓","瀘州","內江","攀枝花","西昌","德陽","雅安","遂甯","南充","綿陽","廣元","瑪律康","達縣","華鑒","自貢","樂山", "其他");


break


case '安徽' :


var labels = new array("合肥","蕪湖","馬鞍山","蚌埠","銅陵","淮北","淮南","亳州","巢湖","黃山","歙縣","宿州","阜陽","六安","滁州","宣州","黃山","安慶", "其他");


var values = new array("合肥","蕪湖","馬鞍山","蚌埠","銅陵","淮北","淮南","亳州","巢湖","黃山","歙縣","宿州","阜陽","六安","滁州","宣州","黃山"," 安慶","其他");


break


case '江西' :


var labels = new array("南昌","景德鎮","九江","鷹潭","宜春","新余","萍鄉","贛州","吉安","井岡山","撫州","臨川","上饒","其他");


var values = new array("南昌","景德鎮","九江","鷹潭","宜春","新余","萍鄉","贛州","吉安","井岡山","撫州","臨川","上饒","其他");


break


case '黑龍江' :


var labels = new array("哈爾濱","佳木斯","牡丹江","大慶","齊齊哈爾","阿城","肇東","綏化","伊春","鶴崗","七台河","雙鴨","同江","綏汾河","雞西","北安", "黑河","五大連池","其他");


var values = new array("哈爾濱","佳木斯","牡丹江","大慶","齊齊哈爾","阿城","肇東","綏化","伊春","鶴崗","七台河","雙鴨","同江","綏汾河","雞西","北安", "黑河","五大連池","其他");


break


case '河北' :


var labels = new array("石家莊","邯鄲","保定","張家口","秦皇島","辛集","邢臺","泊頭","唐山","北戴河","廊坊","定州","南宮","衡水","沙河","滄州","任丘"," 承德","涿州","其他");


var values = new array("石家莊","邯鄲","保定","張家口","秦皇島","辛集","邢臺","泊頭","唐山","北戴河","廊坊","定州","南宮","衡水","沙河","滄州","任丘 ","承德","涿州","其他");


break


case '陝西' :


var labels = new array("西安","咸陽","寶雞","銅川","渭南","延安","漢中","韓城","其他");


var values = new array("西安","咸陽","寶雞","銅川","渭南","延安","漢中","韓城","其他");


break


case '海南' :


var labels = new array("海口","三亞","瓊海","通什","其他");


var values = new array("海口","三亞","瓊海","通什","其他");


break


case '河南' :


var labels = new array("鄭州","洛陽","開封","鶴壁","焦作","許昌","駐馬店","周口","新鄉","安陽","濮陽","漯河","信陽","平頂山","三門峽","南陽","商丘" ,"義馬","其他");


var values = new array("鄭州","洛陽","開封","鶴壁","焦作","許昌","駐馬店","周口","新鄉","安陽","濮陽","漯河","信陽","平頂山","三門峽","南陽","商丘","義馬 ","其他");


break


case '山西' :


var labels = new array("太原","大同","忻州","臨汾","運城","長治","榆次","侯馬","陽泉","晉城","其他");


var values = new array("太原","大同","忻州","臨汾","運城","長治","榆次","侯馬","陽泉","晉城","其他");


break


case '內蒙古' :


var labels = new array("呼和浩特","赤峰","包頭","二連浩特","臨河","東勝","滿洲里","烏蘭浩特","霍林郭勒","集甯","烏海","海拉爾","牙克石","錫林浩特","通遼" ,"紮蘭屯","其他");


var values = new array("呼和浩特","赤峰","包頭","二連浩特","臨河","東勝","滿洲里","烏蘭浩特","霍林郭勒","集甯","烏海","海拉爾","牙克石","錫林浩特","通遼" ,"紮蘭屯","其他");


break


case '廣西' :


var labels = new array("南寧","桂林","北海","柳州","玉林","百色","河池","憑祥","欽州","梧州","合山","其他");


var values = new array("南寧","桂林","北海","柳州","玉林","百色","河池","憑祥","欽州","梧州","合山","其他");


break


case '貴州' :


var labels = new array("貴陽","遵義","銅仁","都勻","興義","赤水","六盤水","凱裡","安順","其他");


var values = new array("貴陽","遵義","銅仁","都勻","興義","赤水","六盤水","凱裡","安順","其他");


break


case '寧夏' :


var labels = new array("銀川","青銅峽","吳忠","石嘴山","中衛","中甯","固原","其他");


var values = new array("銀川","青銅峽","吳忠","石嘴山","中衛","中甯","固原","其他");


break


case '青海' :


var labels = new array("西寧","格爾木","共和","德令哈","其他");


var values = new array("西寧","格爾木","共和","德令哈","其他");


break


case '新疆' :


var labels = new array("烏魯木齊","石河子","克拉瑪依","博樂","塔城","阿勒泰","哈密","阿克蘇","阿圖什","昌吉","奎屯","伊寧","吐魯番","庫爾勒","喀什"," 和田","其他");


var values = new array("烏魯木齊","石河子","克拉瑪依","博樂","塔城","阿勒泰","哈密","阿克蘇","阿圖什","昌吉","奎屯","伊寧","吐魯番","庫爾勒","喀什"," 和田","其他");


break


case '西藏' :


var labels = new array("拉薩","日喀則","其他");


var values = new array("拉薩","日喀則","其他");


break


case '甘肅' :


var labels = new array("蘭州","酒泉","臨夏","張掖","嘉峪關","金昌","平涼","白銀","武威","玉門","天水","西峰","其他");


var values = new array("蘭州","酒泉","臨夏","張掖","嘉峪關","金昌","平涼","白銀","武威","玉門","天水","西峰","其他");


break


case '臺灣' :


var labels = new array("臺北","台中","基隆","台南","其他");


var labels = new array("臺北","台中","基隆","台南","其他");


break


case '香港' :


var labels = new array("香港");


var values = new array("香港");


break


case '澳門' :


var labels = new array("澳門");


var values = new array("澳門");


break


case '國外' :


var labels = new array("國外");


var values = new array("國外");


break

}
instance.options.length = 0;
for(var i = 0; i < labels.length; i++) {
instance.add(document.createelement("option"));
instance.options[i].text=labels[i];
instance.options[i].value=values[i];
if (instance.options[i].value==selectvalue)
instance.options[i].selected=true
}
}

function initecselector(instance,optionlist,selectvalue)
{
 var i, aindex, alength, avaluetext;
& nbsp;instance.length=0;
 instance.options[0] = new option("選擇省份", "0")
 for (i=0;i<optionlist.length;i++)
 {
  avaluetext = optionlist[i].split("|");
  if(avaluetext.length>0)
   instance.options[instance.length] = new option( avaluetext[1], avaluetext[0])
   if (avaluetext[0]==selectvalue)
    instance.options[i].selected=true
 }
}
initecselector(document.getelementbyid("area"),eczones,' 北京');
function zhuanyio()
{
setcity2(document.getelementbyid("area").value,document.getelementbyid("city"), '')
}
</script>

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.