jquery实现二级联动不与数据库交互

<select id="pro" name="pro" style="width:90px;"></select>

<select id="city" name="city" style="width: 90px"></select>


$._cityInfo = [{"n":"北京市","c":["北京市"]},

{"n":"天津市","c":["天津市"]},

{"n":"上海市","c":["上海市"]},

{"n":"重庆市","c":["重庆市"]},

{"n":"河北省","c":["石家庄市","唐山市","秦皇岛市","邯郸市","邢台市","保定市","张家口市","承德市","沧州市","廊坊市","衡水市"]},

{"n":"山西省","c":["太原市","大同市","阳泉市","长治市","晋城市","朔州市","晋中市","运城市","忻州市","临汾市","吕梁市"]},

{"n":"台湾省","c":["台北市","高雄市","基隆市","台中市","台南市","新竹市","嘉义市","台北县","宜兰县","桃园县","新竹县","苗栗县","台中县","彰化县","南投县","云林县","嘉义县","台南县","高雄县","屏东县","澎湖县","台东县","花莲县"]},

{"n":"辽宁省","c":["沈阳市","大连市","鞍山市","抚顺市","本溪市","丹东市","锦州市","营口市","阜新市","辽阳市","盘锦市","铁岭市","朝阳市","葫芦岛市"]},

{"n":"吉林省","c":["长春市","吉林市","四平市","辽源市","通化市","白山市","松原市","白城市","延边朝鲜族自治州"]},

{"n":"黑龙江省","c":["哈尔滨市","齐齐哈尔市","鹤岗市","双鸭山市","鸡西市","大庆市","伊春市","牡丹江市","佳木斯市","七台河市","黑河市","绥化市","大兴安岭地区"]},

{"n":"江苏省","c":["南京市","无锡市","徐州市","常州市","苏州市","南通市","连云港市","淮安市","盐城市","扬州市","镇江市","泰州市","宿迁市"]},

{"n":"浙江省","c":["杭州市","宁波市","温州市","嘉兴市","湖州市","绍兴市","金华市","衢州市","舟山市","台州市","丽水市"]},

{"n":"安徽省","c":["合肥市","芜湖市","蚌埠市","淮南市","马鞍山市","淮北市","铜陵市","安庆市","黄山市","滁州市","阜阳市","宿州市","巢湖市","六安市","亳州市","池州市","宣城市"]},

{"n":"福建省","c":["福州市","厦门市","莆田市","三明市","泉州市","漳州市","南平市","龙岩市","宁德市"]},

{"n":"江西省","c":["南昌市","景德镇市","萍乡市","九江市","新余市","鹰潭市","赣州市","吉安市","宜春市","抚州市","上饶市"]},

{"n":"山东省","c":["济南市","青岛市","淄博市","枣庄市","东营市","烟台市","潍坊市","济宁市","泰安市","威海市","日照市","莱芜市","临沂市","德州市","聊城市","滨州市","荷泽市"]},

{"n":"河南省","c":["郑州市","开封市","洛阳市","平顶山市","安阳市","鹤壁市","新乡市","焦作市","濮阳市","许昌市","漯河市","三门峡市","南阳市","商丘市","信阳市","周口市","驻马店市"]},

{"n":"湖北省","c":["武汉市","黄石市","十堰市","宜昌市","襄樊市","鄂州市","荆门市","孝感市","荆州市","黄冈市","咸宁市","随州市","恩施土家族苗族自治州","仙桃市","潜江市","天门市","神农架林区"]},

{"n":"湖南省","c":["长沙市","株洲市","湘潭市","衡阳市","邵阳市","岳阳市","常德市","张家界市","益阳市","郴州市","永州市","怀化市","娄底市","湘西土家族苗族自治州"]},

{"n":"广东省","c":["广州市","深圳市","珠海市","汕头市","韶关市","佛山市","江门市","湛江市","茂名市","肇庆市","惠州市","梅州市","汕尾市","河源市","阳江市","清远市","东莞市","中山市","潮州市","揭阳市","云浮市"]},

{"n":"甘肃省","c":["兰州市","金昌市","白银市","天水市","嘉峪关市","武威市","张掖市","平凉市","酒泉市","庆阳市","定西市","陇南市","临夏回族自治州","甘南藏族自治州"]},

{"n":"四川省","c":["成都市","自贡市","攀枝花市","泸州市","德阳市","绵阳市","广元市","遂宁市","内江市","乐山市","南充市","眉山市","宜宾市","广安市","达州市","雅安市","巴中市","资阳市","阿坝藏族羌族自治州","甘孜藏族自治州","凉山彝族自治州"]},

{"n":"贵州省","c":["贵阳市","六盘水市","遵义市","安顺市","铜仁地区","毕节地区","黔西南布依族苗族自治州","黔东南苗族侗族自治州","黔南布依族苗族自治州"]},

{"n":"海南省","c":["海口市","三亚市","五指山市","琼海市","儋州市","文昌市","万宁市","东方市","澄迈县","定安县","屯昌县","临高县","白沙黎族自治县","昌江黎族自治县","乐东黎族自治县","陵水黎族自治县","保亭黎族苗族自治县","琼中黎族苗族自治县"]},

{"n":"云南省","c":["昆明市","曲靖市","玉溪市","保山市","昭通市","丽江市","思茅市","临沧市","楚雄彝族自治州","红河哈尼族彝族自治州","文山壮族苗族自治州","西双版纳傣族自治州","大理白族自治州","德宏傣族景颇族自治州","怒江傈僳族自治州","迪庆藏族自治州"]},

{"n":"青海省","c":["西宁市","海东地区","海北藏族自治州","黄南藏族自治州","海南藏族自治州","果洛藏族自治州","玉树藏族自治州","海西蒙古族藏族自治州"]},

{"n":"陕西省","c":["西安市","铜川市","宝鸡市","咸阳市","渭南市","延安市","汉中市","榆林市","安康市","商洛市"]},

{"n":"广西壮族自治区","c":["南宁市","柳州市","桂林市","梧州市","北海市","防城港市","钦州市","贵港市","玉林市","百色市","贺州市","河池市","来宾市","崇左市"]},

{"n":"西藏自治区","c":["拉萨市","昌都地区","山南地区","日喀则地区","那曲地区","阿里地区","林芝地区"]},

{"n":"宁夏回族自治区","c":["银川市","石嘴山市","吴忠市","固原市","中卫市"]}];


$.initProv = function(prov, city, defaultProv, defaultCity) {

    var provEl = $(prov);

    var cityEl = $(city);

    var hasDefaultProv = (typeof(defaultCity) != 'undefined');

    

    var provHtml = '';

    

   // provHtml += '<option value="-1">请选择</option>';

    for(var i = 0; i < $._cityInfo.length; i++) {

        provHtml += '<option value="' + i + '"' + ((hasDefaultProv && $._cityInfo[i].n == defaultProv) ? ' selected="selected"' : '') + '>' + $._cityInfo[i].n + '</option>';

    }

    provEl.html(provHtml);

    $.initCities(provEl, cityEl, defaultCity);

    provEl.change(function() {

        $.initCities(provEl, cityEl);

    });

};


$.initCities = function(provEl, cityEl, defaultCity) {

    var hasDefaultCity = (typeof(defaultCity) != 'undefined');

    //alert(provEl.attr("name"))

    if(provEl.val() != '' && parseInt(provEl.val()) >= 0) {

        var cities = $._cityInfo[parseInt(provEl.val())].c;

        var cityHtml = '';

        

        //cityHtml += '<option value="'+cities[0]+'">'+cities[0]+'</option>';

        for(var i = 0; i < cities.length; i++) {

            cityHtml += '<option value="' + cities[i] + '"' + ((hasDefaultCity && cities[i] == defaultCity) ? ' selected="selected"' : '') + '>' + cities[i] + '</option>';

        }

        cityEl.html(cityHtml);

    } else {

        cityEl.html('<option value="-1">请先选择</option>');

    }

};

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/273523.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

[016]转--C++拷贝构造函数详解

一. 什么是拷贝构造函数 首先对于普通类型的对象来说&#xff0c;它们之间的复制是很简单的&#xff0c;例如&#xff1a; [c-sharp] view plaincopy int a 100; int b a; 而类对象与普通对象不同&#xff0c;类对象内部结构一般较为复杂&#xff0c;存在各种成员变量。下…

js中调用C标签实现百度地图

<script type"text/javascript"> //json数组 var jsonArray document.getElementById("restaurant").value; var map new BMap.Map("milkMap"); // 创建地图实例 <c:forEach items"${restaurantlist}" var"…

jquery较验组织机构编码

//*************************组织机构码较验************************* function checkOrganizationCode() { var weight [3, 7, 9, 10, 5, 8, 4, 2]; var str 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ; var reg /^([0-9A-Z]){8}-[0-9|X]{1}$/; var organizationcode $("…

自定义GrildView实现单选功能

首先看实现功能截图&#xff0c;这是一个自定义Dialog,并且里面内容由GrildView 绑定数据源&#xff0c;实现类似单选功能。 首先自定义Dialog&#xff0c;绑定数据源 自定义Dialog弹出框大小方法 最主要实现的就是点击颜色切换的功能&#xff0c;默认GrildView的每一项都是蓝色…

Java数字字符串如何转化为数字数组

eg&#xff1a; String numberString "0123456789"; 如何转化为&#xff1a;int[] digitArry new int[]{0,1,2,3,4,5,6,7,8,9}; 解决办法&#xff1a; char[] digitNumberArray numberString.toCharArray(); int[] digitArry new int[digitString.toCharArray().l…

『重构--改善既有代码的设计』读书笔记----序

作为C的程序员&#xff0c;我从大学就开始不间断的看书&#xff0c;看到如今上班&#xff0c;也始终坚持每天多多少少阅读技术文章&#xff0c;书看的很多&#xff0c;但很难有一本书&#xff0c;能让我去反复的翻阅。但唯独『重构--改善既有代码的设计』这本书让我重复看了不下…

微信公共平台接口开发--Java实现

Java微信实现&#xff0c;采用SpringMVC 架构&#xff0c;采用SAXReader解析XML RequestMapping(value"/extend") public class WeixinController { RequestMapping(value"/weixin") public ModelAndView weixin(HttpServletRequest request,HttpServlet…

最大权闭合图hdu3996

定义&#xff1a;最大权闭合图&#xff1a;是有向图的一个点集&#xff0c;且该点集的所有出边都指向该集合。即闭合图内任意点的集合也在改闭合图内&#xff0c;给每个点分配一个点权值Pu&#xff0c;最大权闭合图就是使闭合图的点权之和最大。 最小割建边方式&#xff1a;源点…

非监督学习的单层网络分析

这篇博客对应的是Andrew.Ng的那篇文章&#xff1a;An Analysis o f Single-Layer Networks in Unsupervised Feature Learning&#xff0c;文章的主要目的是讨论receptive field size&#xff0c;number of hidden nodes&#xff0c; step-stride以及whitening在对卷积网络模型…

Spring MVC 验证码

页面 <% page language"java" import"java.util.*" pageEncoding"UTF-8"%> <% String path request.getContextPath(); String basePath request.getScheme()"://"request.getServerName()":"request.getServerP…

数据结构实验之链表四:有序链表的归并

数据结构实验之链表四&#xff1a;有序链表的归并 Time Limit: 1000MS Memory limit: 65536K 题目描述 分别输入两个有序的整数序列&#xff08;分别包含M和N个数据&#xff09;&#xff0c;建立两个有序的单链表&#xff0c;将这两个有序单链表合并成为一个大的有序单链表&…

apk文件编译到系统文件中的方法(及包含so库的)

把第三方或自己开发的apk文件编译到系统文件(system.img)中的方法&#xff1a; 1 (1)源码编译后&#xff0c;把apk拷贝到out\target\product\generic\system\app中。 (2) 执行命令make snod , 把添加的spk编到system.img 中 缺点&#xff1a;执行make clean 后&#xff0c;再…

javascript中interval与setTimeOut的区别

setTimeout(code,millisec) //- 在指定时间后执行代码 code必须&#xff1b; millisec必须&#xff1b; clearTimeout(setTimeoutId) //- 取消 setTimeout() setInterval(code,millisec)&#xff1b;//指定间隔毫秒内循环执行代码 code必须&#xff1b; millisec必须&a…

java设计模式之单例模式(七种方法)

单例模式&#xff1a;个人认为这个是最简单的一种设计模式&#xff0c;而且也是在我们开发中最常用的一个设计模式。 单例模式的意思就是只有一个实例。单例模式确保某一个类只有一个实例&#xff0c;而且自行实例化并向整个系统提供这个实例。这个类称为单例类。我们前面学习的…

java 遍历map集合

Map<String, String> map new HashMap<String, String>(); map.put("key1", "value1"); map.put("key2", "value2"); map.put("key3", "value3"); //第一种&#xff1a;通过Map.keySet遍…

poj3009 Curling 2.0 深搜

PS&#xff1a;以前看到题目这么长就没写下去了。今天做了半天&#xff0c;没做出来。准备看题解&#xff0c;打开了网站都忍住了&#xff0c;最后还是靠自己做出来的。算是一点进步吧。 分析&#xff1a; 题目的意思没明白或者理解有偏差都没办法做题。看样例3和样例4&#xf…

Android监听事件

ListView事件监听&#xff1a; setOnItemSelectedListener 鼠标滚动时触发 setOnItemClickListener 点击时触发 EditText事件监听&#xff1a; setOnKeyListener 获取焦点时触发 RadioGroup事件监听&#xff1a; setOnCheckedChangeListener 点击时触发 CheckBox事件监听&#…

子类能不能继承父类的构造方法?

class A{ public A(){} // 1:无参数构造方法。 public A(String s){} // 2.}class B extends A{ public B(String s){ super(s); // 3. }}说明&#xff1a;如果没有1处的无参数构造方法&#xff0c;那么3处一定要主动调用父类带参数的构造方法。如果有1处的构造方法&#…

基于原生javascript的ajax实现

function getXMLHttpRequest(){if(window.ActiveXObject){//用户是ie浏览器http_requestnew ActiveXObject("Microsoft.XMLHTTP");}else{//其他的浏览器http_requestnew XMLHttpRequest();}return http_request;}var httpRequest;function name(){httpRequestgetXMLH…

Google File System设计方面的问题汇总

1、Google File System概述 google file system是一个分布式文件系统&#xff0c;针对的是数据密集型应用&#xff0c;提供容错功能&#xff0c;运行在低廉的服务器上&#xff0c;同时给大量的用户提供高性能服务。尽管google file system有着传统的分布式文件系统的目标&#…