1. function cn(){
  2. this.Items = {};
  3. }
  4. cn.prototype.add = function(id,iArray){
  5. this.Items[id] = iArray;
  6. }
  7. cn.prototype.Exi = function(id){
  8. if(typeof(this.Items[id]) == "undefined"){return false;}
  9. return true;
  10. }
  11. function chg(v){
  12. if(v==3){return;}
  13. var str="0";
  14. for(i=0;i<v;i++){str+=("_"+(document.getElementById(s[i]).selectedIndex))};
  15. var ss=document.getElementById(s[v]);
  16. with(ss){
  17. length = 0; //清理掉option
  18. if(a_t.Exi(str)){
  19. ar=a_t.Items[str];
  20. for(i=0;i<ar.length;i++){
  21. options[length]=new Option(ar[i],ar[i]);
  22. if(ar[i]==o[v]){options[i].selected=true;}//如果列表内包含初始项目则默认选中
  23. }
  24. }
  25. if(++v<s.length){chg(v);}
  26. }
  27. }
  28. var s=["tid1","province","city"];
  29. var o=["中国","广东","深圳"];
  30. function setup(){
  31. for(i=1;i<=3;i++){
  32. document.getElementById(s[(i-1)]).onchange=new Function("chg("+(i)+")");
  33. }
  34. chg(0);
  35. }
  36. var a_t = new cn();
  37. a_t.add("0",["中国","韩国","台湾"]);
  38. a_t.add("0_0",["安徽","北京","福建","甘肃","广东","广西","贵州","海南","河北","河南","黑龙江","湖北","湖南","吉林","江苏","江西","辽宁","内蒙古","宁夏","青海","山东","山西"]);
  39. a_t.add("0_0_0",["安庆","蚌埠","巢湖","池州","滁州","阜阳","合肥","淮北","淮南","黄山","六安","马鞍山","宿州","铜陵","芜湖","宣城","亳州"]);
  40. a_t.add("0_0_1",["北京"]);
  41. a_t.add("0_0_2",["福州","龙岩","南平","宁德","莆田","泉州","三明","厦门","漳州"]);
  42. a_t.add("0_0_3",["白银","定西","甘南藏族自治州","嘉峪关","金昌","酒泉","兰州","临夏回族自治州","陇南","平凉","庆阳","天水","武威","张掖"]);
  43. a_t.add("0_0_4",["潮州","东莞","佛山","广州","河源","深圳","阳江","云浮","湛江","肇庆","中山","珠海"]);
  44. a_t.add("0_0_5",["百色","北海","崇左","防城港","桂林","贵港","河池","贺州","来宾","柳州","南宁","钦州","梧州","玉林"]);
  45. a_t.add("0_0_6",["安顺","毕节","贵阳","六盘水","黔东南苗族侗族自治州","黔南布依族苗族自治州","黔西南布依族苗族自治州","铜仁","遵义"]);
  46. a_t.add("0_0_7",["澄迈县","定安县","东方","海口",,"琼中黎族苗族自治县","三亚","屯昌县","万宁","文昌","五指山","儋州"]);
  47. a_t.add("0_0_8",["保定","沧州","承德","邯郸","衡水","廊坊","秦皇岛","石家庄","唐山","邢台","张家口"]);
  48. a_t.add("0_0_9",["安阳","鹤壁","济源","焦作","开封","洛阳","南阳","平顶山","三门峡","商丘","新乡","信阳","许昌","郑州","周口","驻马店","漯河","濮阳"]);
  49. a_t.add("0_0_10",["大庆","大兴安岭","哈尔滨","鹤岗","黑河","鸡西","佳木斯","牡丹江","七台河","齐齐哈尔","双鸭山","绥化","伊春"]);
  50. a_t.add("0_0_11",["鄂州","恩施土家族苗族自治州","黄冈","黄石","荆门","荆州","潜江","神农架林区","十堰","随州","天门","武汉","仙桃","咸宁","襄樊","孝感","宜昌"]);
  51. a_t.add("0_0_12",["常德","长沙","郴州","衡阳","怀化","娄底","邵阳","湘潭","湘西土家族苗族自治州","益阳","永州","岳阳","张家界","株洲"]);
  52. a_t.add("0_0_13",["白城","白山","长春","吉林","辽源","四平","松原","通化","延边朝鲜族自治州"]);
  53. a_t.add("0_0_14",["常州","淮安","连云港","南京","南通","苏州","宿迁","泰州","无锡","徐州","盐城","扬州","镇江"]);
  54. a_t.add("0_0_15",["抚州","赣州","吉安","景德镇","九江","南昌","萍乡","上饶","新余","宜春","鹰潭"]);
  55. a_t.add("0_0_16",["鞍山","本溪","朝阳","大连","丹东","抚顺","阜新","葫芦岛","锦州","辽阳","盘锦","沈阳","铁岭","营口"]);
  56. a_t.add("0_0_17",["阿拉善盟","巴彦淖尔盟","包头","赤峰","鄂尔多斯","呼和浩特","呼伦贝尔","通辽","乌海","乌兰察布盟","锡林郭勒盟","兴安盟"]);
  57. a_t.add("0_0_18",["固原","石嘴山","吴忠","银川"]);
  58. a_t.add("0_0_19",["果洛藏族自治州","海北藏族自治州","海东","海南藏族自治州","海西蒙古族藏族自治州","黄南藏族自治州","西宁","玉树藏族自治州"]);
  59. a_t.add("0_0_20",["滨州","德州","东营","菏泽","济南","济宁","莱芜","聊城","临沂","青岛","日照","泰安","威海","潍坊","烟台","枣庄","淄博"]);
  60. a_t.add("0_1",["汉城特別市","釜山广域市","大邱广域市","济州道"]);
  61. a_t.add("0_1_0",["汉城"]);
  62. a_t.add("0_1_1",["釜山","机张郡"]);
  63. a_t.add("0_1_2",["大邱","达城郡"]);
  64. a_t.add("0_1_3",["仁川","江华郡","瓮津郡"]);
  65. a_t.add("0_1_4",["光州"]);
  66. a_t.add("0_1_5",["大田"]);
  67. a_t.add("0_1_6",["蔚山","蔚州郡"]);
  68. a_t.add("0_1_7",["水原市","城南市","安山市","高阳市","安养市","富川市"]);
  69. a_t.add("0_1_8",["春川市","原州市","江陵市"]);
  70. a_t.add("0_1_9",["清州市"]);
  71. a_t.add("0_1_10",["天安市"]);
  72. a_t.add("0_1_11",["全州市","群山市","益山市"]);
  73. a_t.add("0_1_12",["木浦市","丽水市","顺天市"]);
  74. a_t.add("0_1_13",["浦项市","龟尾市","庆州市"]);
  75. a_t.add("0_1_14",["昌原市","马山市","晋州市"]);
  76. a_t.add("0_1_15",["济州市","西归浦市","北济州郡","南济州郡"]);
  77. a_t.add("0_2",["基隆","台北","桃园","新竹","苗栗","台中","彰化","南投","云林","嘉义","台南","高雄","台东","花莲"]);
  78. a_t.add("0_2_0",["基隆"]);
  79. a_t.add("0_2_1",["台北"]);
  80. a_t.add("0_2_2",["中壢市","平鎮市","龍潭鄉","楊梅鎮","新屋鄉","觀音鄉","龜山鄉","八德市","大溪鎮","復興鄉","大園鄉","蘆竹鄉"]);
  81. a_t.add("0_2_3",["名古屋市 "]);
  82. a_t.add("0_2_4",["札幌市"]);
  83. a_t.add("0_2_5",["神戸市"]);
  84. a_t.add("0_2_6",["京都市"]);
  85. a_t.add("0_2_7",["福冈市"]);
  86. a_t.add("0_2_8",["川崎市"]);
  87. a_t.add("0_2_9",["埼玉市"]);
  88. a_t.add("0_2_10",["广岛市"]);
  89. a_t.add("0_2_11",["仙台市"]);
  90. a_t.add("0_2_12",["北九州市 "]);
  91. a_t.add("0_2_13",["千叶市"]);


Js 省市联动的更多相关文章

  1. [JS]以下是JS省市联动菜单代码

    以下是JS省市联动菜单代码: 代码一: <html> <head> <title></title> <script language=" ...

  2. JS 省市联动 ajax

    省市联动 //省市联动     $('.locationCode').change(function () {         var val = $(this).val();         if ...

  3. 前端js 省市联动

    代码下载地址 <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www. ...

  4. js省市联动

    <html> <head> <script src="http://files.cnblogs.com/files/beiz/jquery-1.8.3.js&q ...

  5. 省市联动 纯html+js

    在js里面声明所有数据,并根据html的select事件触发js实现填充对应的数据到下拉框. 代码 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...

  6. js实现的省市联动

    最近工作,要用到省市联动的功能.网上搜了一下,发现有很多这样的例子,看了不少实例,把觉得写得不错的代码穿上来,好给大家分享一下. <!DOCTYPE html PUBLIC "-//W ...

  7. JavaScript(JS)实现省市联动选择下拉列表

    在开发一个应用的时候需要用刀省市联动的下拉列表,网上找到不少.但是要么太复杂,难以修改:要么根本就用不了,最后自己在一个示例中提取出数据,然后自己写了一个,简单易懂,适合新手... 代码如下: Pro ...

  8. html css javascript 知识点总结 bom js 操作标签 文本 节点 表格各行变色 悬停变色 省市联动 正则

    <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title&g ...

  9. 省市联动 js

    工作中见到这个省市联动代码,虽然很简单也能写出来,还是随便把它记录下来. //省市联动 function area(obj_id, area_pId, data_call_back) { ) retu ...

随机推荐

  1. 常用EDA工具环境变量配置

    # EDA Toolsexport SYNOPSYS_HOME=/home/ProgramFiles/synopsysexport VCS_ARCH_OVERRIDE=linuxexport VCS_ ...

  2. SpringSecurity实现后台管理员登录(二)

    需求:login.ftl页面中登录成功后进入index.ftl页面中 一.pom.xml中添加json转换相关的包 <dependency> <groupId>com.fast ...

  3. 关于docker的15个小tip

    1. 获取最近运行容器的id 这是我们经常会用到的一个操作,按照官方示例,你可以这样做(环境ubuntu): $ ID=$(docker run ubuntu echo hello world) he ...

  4. 使用webService时,gsoap数据类型注意事项

    今天在使用gsoap生成webservice客户端文件时,发现我的参数类型全被改了,比如string型变成了char*,原来有STL的地方也变没了,经过研究发现,原来和我生成的头文件时使用的参数有关, ...

  5. HDU 2222 AC自动机模版题

    所学的AC自动机都源于斌哥和昀神的想法. 题意:求目标串中出现了几个模式串. 使用一个int型的end数组记录,查询一次. #include <cstdio> #include <c ...

  6. 微信小程序 - 选取搜索地点并且显示(map)

    演示如下,使用时,你也许会配合它:腾讯地图路线规划 wxml: <view class='address' bindtap='onChangeAddress'> <input cla ...

  7. vue - 页面跳转

    HTML:a 小程序:navigator Vue:router-link 1. router-link => a标签 2. javascript标签跳转页面 2.1   2.2 3. 常用方法之 ...

  8. windows下flv视频网站进度条随意拖放[转]

    网站中视频都转换成flv格式,奈何flv格式无法拖拽,此问题纠结了好久,最终得以解决.现将解决思路记录下来,大多数源于网上找到的. 视频拖拽满足要求 1.播放器要支持 2.flv视频要有关键帧和met ...

  9. 算法笔记_135:格子取数问题(Java)

    目录 1 问题描述 2 解决方案   1 问题描述 有n*n个格子,每个格子里有正数或者0,从最左上角往最右下角走,只能向下和向右走,一共走两次(即从左上角往右下角走两趟),把所有经过的格子里的数加起 ...

  10. volist 自增序号 分页如何实现?

    TP框架模板中如何生成自增数据 {$_GET['p']*10-10+$i} /* 分页序号计算    */ function addnum($k,$num){     return ($k +1 ) ...