var arrSelectName = new Array(document.getElementById("drpProvince"),document.getElementById("drpCity"));
var arrList = new Array([999999,0,'--请选择--',''],[999998,999999,'--请选择--',''],[1,0,'安徽','1'],[36,1,'安庆','36'],[37,1,'蚌埠','37'],[38,1,'亳州','38'],[39,1,'巢湖','39'],[40,1,'滁州','40'],[41,1,'阜阳','41'],[42,1,'贵池','42'],[35,1,'合肥','35'],[43,1,'淮北','43'],[44,1,'淮化','44'],[45,1,'淮南','45'],[46,1,'黄山','46'],[47,1,'九华山','47'],[48,1,'六安','48'],[49,1,'马鞍山','49'],[50,1,'宿州','50'],[51,1,'铜陵','51'],[52,1,'屯溪','52'],[53,1,'芜湖','53'],[54,1,'宣城','54'],[20,0,'澳门','20'],[281,20,'澳门','281'],[2,0,'北京','2'],[55,2,'北京','55'],[4,0,'福建','4'],[58,4,'福安','58'],[57,4,'福州','57'],[59,4,'龙岩','59'],[60,4,'南平','60'],[61,4,'宁德','61'],[62,4,'莆田','62'],[63,4,'泉州','63'],[64,4,'三明','64'],[65,4,'邵武','65'],[66,4,'石狮','66'],[68,4,'武夷山','68'],[69,4,'厦门','69'],[67,4,'永安','67'],[70,4,'漳州','70'],[5,0,'甘肃','5'],[72,5,'白银','72'],[73,5,'定西','73'],[74,5,'敦煌','74'],[75,5,'甘南','75'],[76,5,'金昌','76'],[77,5,'酒泉','77'],[71,5,'兰州','71'],[78,5,'临夏','78'],[79,5,'平凉','79'],[80,5,'天水','80'],[81,5,'武都','81'],[82,5,'西峰','82'],[83,5,'张掖','83'],[6,0,'广东','6'],[85,6,'潮阳','85'],[86,6,'潮州','86'],[87,6,'澄海','87'],[88,6,'东莞','88'],[89,6,'佛山','89'],[84,6,'广州','84'],[90,6,'河源','90'],[91,6,'惠州','91'],[92,6,'江门','92'],[93,6,'揭阳','93'],[94,6,'开平','94'],[95,6,'茂名','95'],[96,6,'梅州','96'],[97,6,'清远','97'],[98,6,'汕头','98'],[99,6,'汕尾','99'],[100,6,'韶关','100'],[101,6,'深圳','101'],[102,6,'顺德','102'],[103,6,'阳江','103'],[104,6,'英德','104'],[105,6,'云浮','105'],[106,6,'增城','106'],[107,6,'湛江','107'],[108,6,'肇庆','108'],[109,6,'中山','109'],[110,6,'珠海','110'],[7,0,'广西','7'],[112,7,'百色','112'],[113,7,'北海','113'],[115,7,'防城港','115'],[114,7,'桂林','114'],[116,7,'河池','116'],[117,7,'柳州','117'],[111,7,'南宁','111'],[118,7,'钦州','118'],[119,7,'梧州','119'],[120,7,'玉林','120'],[8,0,'贵州','8'],[122,8,'安顺','122'],[123,8,'毕节','123'],[124,8,'都匀','124'],[121,8,'贵阳','121'],[125,8,'凯里','125'],[126,8,'六盘水','126'],[127,8,'铜仁','127'],[128,8,'兴义','128'],[129,8,'玉屏','129'],[130,8,'遵义','130'],[9,0,'海南','9'],[132,9,'儋县','132'],[131,9,'海口','131'],[133,9,'陵水','133'],[134,9,'琼海','134'],[135,9,'三亚','135'],[136,9,'通什','136'],[137,9,'万宁','137'],[10,0,'河北','10'],[139,10,'保定','139'],[140,10,'北戴河','140'],[141,10,'沧州','141'],[142,10,'承德','142'],[143,10,'丰润','143'],[144,10,'邯郸','144'],[145,10,'衡水','145'],[146,10,'廊坊','146'],[147,10,'南戴河','147'],[148,10,'秦皇岛','148'],[138,10,'石家庄','138'],[149,10,'唐山','149'],[150,10,'新城','150'],[151,10,'邢台','151'],[152,10,'张家口','152'],[12,0,'河南','12'],[168,12,'安阳','168'],[169,12,'鹤壁','169'],[170,12,'潢川','170'],[171,12,'焦作','171'],[172,12,'开封','172'],[174,12,'洛阳','174'],[173,12,'漯河','173'],[175,12,'南阳','175'],[176,12,'平顶山','176'],[177,12,'濮阳','177'],[178,12,'三门峡','178'],[179,12,'商丘','179'],[180,12,'新乡','180'],[181,12,'信阳','181'],[182,12,'许昌','182'],[167,12,'郑州','167'],[183,12,'周口','183'],[184,12,'驻马店','184'],[11,0,'黑龙江','11'],[154,11,'北安','154'],[155,11,'大庆','155'],[156,11,'大兴安岭','156'],[153,11,'哈尔滨','153'],[157,11,'鹤岗','157'],[158,11,'黑河','158'],[160,11,'鸡西','160'],[159,11,'佳木斯','159'],[161,11,'牡丹江','161'],[163,11,'七台河','163'],[162,11,'齐齐哈尔','162'],[164,11,'双鸭山','164'],[165,11,'绥化','165'],[166,11,'伊春','166'],[14,0,'湖北','14'],[189,14,'鄂州','189'],[188,14,'恩施','188'],[190,14,'黄岗','190'],[191,14,'黄石','191'],[192,14,'荆门','192'],[193,14,'荆州','193'],[194,14,'潜江','194'],[195,14,'十堰','195'],[196,14,'随州','196'],[187,14,'武汉','187'],[197,14,'武穴','197'],[198,14,'仙桃','198'],[199,14,'咸宁','199'],[201,14,'襄樊','201'],[200,14,'襄阳','200'],[202,14,'孝感','202'],[203,14,'宜昌','203'],[15,0,'湖南','15'],[204,15,'长沙','204'],[205,15,'常德','205'],[206,15,'郴州','206'],[207,15,'衡阳','207'],[208,15,'怀化','208'],[209,15,'吉首','209'],[210,15,'娄底','210'],[211,15,'邵阳','211'],[212,15,'湘潭','212'],[213,15,'益阳','213'],[215,15,'永州','215'],[214,15,'岳阳','214'],[216,15,'张家界','216'],[217,15,'株洲','217'],[18,0,'吉林','18'],[257,18,'白城','257'],[258,18,'白山','258'],[256,18,'长春','256'],[259,18,'珲春','259'],[262,18,'吉林','262'],[260,18,'辽源','260'],[261,18,'梅河','261'],[263,18,'四平','263'],[264,18,'松原','264'],[265,18,'通化','265'],[266,18,'延吉','266'],[16,0,'江苏','16'],[219,16,'常熟','219'],[220,16,'常州','220'],[221,16,'海门','221'],[222,16,'淮安','222'],[223,16,'江都','223'],[224,16,'江阴','224'],[225,16,'昆山','225'],[226,16,'连云港','226'],[218,16,'南京','218'],[227,16,'南通','227'],[228,16,'启东','228'],[229,16,'沭阳','229'],[230,16,'苏州','230'],[231,16,'太仓','231'],[232,16,'泰州','232'],[233,16,'同里','233'],[234,16,'无锡','234'],[235,16,'徐州','235'],[236,16,'盐城','236'],[237,16,'扬州','237'],[239,16,'仪征','239'],[238,16,'宜兴','238'],[240,16,'张家港','240'],[241,16,'镇江','241'],[242,16,'周庄','242'],[17,0,'江西','17'],[244,17,'抚州','244'],[245,17,'赣州','245'],[246,17,'吉安','246'],[248,17,'井冈山','248'],[247,17,'景德镇','247'],[249,17,'九江','249'],[250,17,'庐山','250'],[243,17,'南昌','243'],[251,17,'萍乡','251'],[252,17,'上饶','252'],[253,17,'新余','253'],[254,17,'宜春','254'],[255,17,'鹰潭','255'],[19,0,'辽宁','19'],[268,19,'鞍山','268'],[269,19,'本溪','269'],[270,19,'朝阳','270'],[271,19,'大连','271'],[272,19,'丹东','272'],[273,19,'抚顺','273'],[274,19,'阜新','274'],[275,19,'葫芦岛','275'],[276,19,'锦州','276'],[277,19,'辽阳','277'],[278,19,'盘锦','278'],[267,19,'沈阳','267'],[279,19,'铁岭','279'],[280,19,'营口','280'],[21,0,'内蒙古','21'],[283,21,'阿拉善盟','283'],[284,21,'包头','284'],[285,21,'赤峰','285'],[286,21,'东胜','286'],[287,21,'海拉尔','287'],[282,21,'呼和浩特','282'],[288,21,'集宁','288'],[289,21,'临河','289'],[290,21,'通辽','290'],[291,21,'乌海','291'],[292,21,'乌兰浩特','292'],[293,21,'锡林浩特','293'],[22,0,'宁夏','22'],[295,22,'固源','295'],[296,22,'石嘴山','296'],[297,22,'吴忠','297'],[294,22,'银川','294'],[23,0,'青海','23'],[299,23,'德令哈','299'],[300,23,'格尔木','300'],[301,23,'共和','301'],[302,23,'海东','302'],[303,23,'海晏','303'],[304,23,'玛沁','304'],[305,23,'同仁','305'],[298,23,'西宁','298'],[306,23,'玉树','306'],[24,0,'山东','24'],[308,24,'滨州','308'],[310,24,'德州','310'],[311,24,'东营','311'],[312,24,'荷泽','312'],[307,24,'济南','307'],[313,24,'济宁','313'],[314,24,'莱芜','314'],[315,24,'聊城','315'],[316,24,'临沂','316'],[317,24,'蓬莱','317'],[318,24,'青岛','318'],[319,24,'曲阜','319'],[320,24,'日照','320'],[321,24,'泰安','321'],[323,24,'威海','323'],[322,24,'潍坊','322'],[324,24,'烟台','324'],[309,24,'兖州','309'],[325,24,'枣庄','325'],[326,24,'淄博','326'],[26,0,'山西','26'],[331,26,'长治','331'],[332,26,'大同','332'],[333,26,'候马','333'],[334,26,'晋城','334'],[335,26,'离石','335'],[336,26,'临汾','336'],[337,26,'宁武','337'],[338,26,'朔州','338'],[330,26,'太原','330'],[339,26,'忻州','339'],[340,26,'阳泉','340'],[341,26,'榆次','341'],[342,26,'运城','342'],[27,0,'陕西','27'],[344,27,'安康','344'],[345,27,'宝鸡','345'],[346,27,'汉中','346'],[348,27,'商州','348'],[349,27,'绥德','349'],[350,27,'铜川','350'],[347,27,'渭南','347'],[343,27,'西安','343'],[351,27,'咸阳','351'],[352,27,'延安','352'],[353,27,'榆林','353'],[25,0,'上海','25'],[328,25,'崇明','328'],[327,25,'上海','327'],[329,25,'朱家角','329'],[28,0,'四川','28'],[355,28,'巴中','355'],[354,28,'成都','354'],[356,28,'达安','356'],[357,28,'德阳','357'],[358,28,'都江堰','358'],[359,28,'峨眉山','359'],[360,28,'涪陵','360'],[361,28,'广安','361'],[362,28,'广元','362'],[363,28,'九寨沟','363'],[364,28,'康定','364'],[365,28,'乐山','365'],[366,28,'泸州','366'],[367,28,'马尔康','367'],[368,28,'绵阳','368'],[370,28,'内江','370'],[369,28,'南充','369'],[371,28,'攀枝花','371'],[372,28,'遂宁','372'],[373,28,'汶川','373'],[374,28,'西昌','374'],[375,28,'雅安','375'],[376,28,'宜宾','376'],[377,28,'自贡','377'],[29,0,'台湾','29'],[379,29,'基隆','379'],[378,29,'台北','378'],[380,29,'台南','380'],[381,29,'台中','381'],[30,0,'天津','30'],[382,30,'天津','382'],[32,0,'西藏','32'],[402,32,'阿里','402'],[403,32,'昌都','403'],[401,32,'拉萨','401'],[404,32,'林芝','404'],[405,32,'那曲','405'],[406,32,'日喀则','406'],[407,32,'山南','407'],[13,0,'香港','13'],[186,13,'九龙','186'],[185,13,'香港','185'],[31,0,'新疆','31'],[384,31,'阿克苏','384'],[385,31,'阿勒泰','385'],[386,31,'阿图什','386'],[387,31,'博乐','387'],[388,31,'昌吉','388'],[389,31,'东山','389'],[390,31,'哈密','390'],[391,31,'和田','391'],[392,31,'喀什','392'],[393,31,'克拉玛依','393'],[394,31,'库车','394'],[395,31,'库尔勒','395'],[396,31,'奎屯','396'],[397,31,'石河子','397'],[398,31,'塔城','398'],[399,31,'吐鲁番','399'],[383,31,'乌鲁木齐','383'],[400,31,'伊宁','400'],[33,0,'云南','33'],[410,33,'保山','410'],[411,33,'楚雄','411'],[409,33,'大理','409'],[412,33,'大理','412'],[413,33,'东川','413'],[414,33,'个旧','414'],[415,33,'景洪','415'],[416,33,'开远','416'],[408,33,'昆明','408'],[418,33,'丽江','418'],[417,33,'临沧','417'],[419,33,'六库','419'],[420,33,'潞西','420'],[421,33,'曲靖','421'],[422,33,'思茅','422'],[423,33,'文山','423'],[424,33,'西双版纳','424'],[425,33,'玉溪','425'],[427,33,'昭通','427'],[426,33,'中甸','426'],[34,0,'浙江','34'],[429,34,'安吉','429'],[430,34,'慈溪','430'],[431,34,'定海','431'],[432,34,'奉化','432'],[433,34,'海盐','433'],[428,34,'杭州','428'],[435,34,'湖州','435'],[434,34,'黄岩','434'],[436,34,'嘉兴','436'],[437,34,'金华','437'],[440,34,'丽水','440'],[438,34,'临安','438'],[439,34,'临海','439'],[441,34,'宁波','441'],[442,34,'瓯海','442'],[443,34,'平湖','443'],[444,34,'千岛湖','444'],[445,34,'衢州','445'],[446,34,'瑞安','446'],[447,34,'绍兴','447'],[448,34,'嵊州','448'],[449,34,'台州','449'],[450,34,'温岭','450'],[451,34,'温州','451'],[3,0,'重庆','3'],[56,3,'重庆','56'],[]);
var arrDefault = new Array();
arrDefault[0] = 'ProvinceID';
arrDefault[1] = 'CityID';
//无限级分类select函数相关
(function (strInitID, arrSelect, arrMatrix, arrDefValue) {
function doChange(iIndex) {
var iCount = 0;
var sParentID = strInitID;
if (iIndex > 0) sParentID = arrSelect[iIndex - 1].options[arrSelect[iIndex - 1].selectedIndex].ID;
with (arrSelect[iIndex]) {
length = 0;
for (var i = 0; i < arrMatrix.length; i++) {
if (String(arrMatrix[i][1]) == String(sParentID)) {
var oNewOption = new Option(arrMatrix[i][2], arrMatrix[i][3], false, false);
oNewOption.ID = arrMatrix[i][0];
options[iCount++] = oNewOption;
if(arrMatrix[i][3] == arrDefValue[iIndex])options[iCount - 1].selected = true;
};
};
if (iCount == 0) {
var oNull = new Option("--", null, false, true);
oNull.ID = "_0x" + (new Date()).getTime();
options[0] = oNull;
};
if (++iIndex < arrSelect.length) doChange(iIndex);
};
};
if (!arrDefValue) arrDefValue = [];
for (var i = 0; i < arrSelect.length - 1; i++) {
eval("arrSelect[" + i + "].onchange = function(){ doChange(" + (i + 1) + "); };");
}
doChange(0);
arrDefValue = [];
})(0,arrSelectName,arrList,arrDefault);
分享到:
相关推荐
《dropList v1.1:JavaScript无限级联动下拉列表框深度解析》 在Web开发中,用户界面的交互性和易用性至关重要。一个优秀的下拉列表框不仅可以提高用户体验,还能有效节省页面空间。今天我们将深入探讨“dropList v...
dropList v1.0-无限级联动下拉框JavaScript类 1、无限制多级联动 2、支持选择状态保存,使用Cookie 3、支持初始值选定 4、同一页面中多个应用不会相互影响 包含一个省市县三级联动的例子
JavaScript 事件处理 下拉列表和可选项 示例代码JavaScript 事件处理 下拉列表和可选项 示例代码JavaScript 事件处理 下拉列表和可选项 示例代码JavaScript 事件处理 下拉列表和可选项 示例代码JavaScript 事件处理 ...
而通过AJAX,我们可以实现这些下拉列表的联动,即用户选择一个省后,相应的市(县)下拉列表会自动更新,无需刷新整个页面,提高用户体验。 实现这个功能的关键步骤包括: 1. **HTML结构**:首先,我们需要在HTML...
在下拉列表联动的例子中,JavaScript通过Ajax异步地向Servlet发送请求,并接收响应。使用XMLHttpRequest对象或者现代浏览器中的fetch API,JavaScript可以监听下拉列表的改变事件,触发Ajax请求,并在接收到Servlet...
### JavaScript操作Select下拉列表框的关键技术点 #### 一、背景与需求分析 在Web应用开发中,经常需要处理用户界面的各种交互行为。本文档介绍了一种利用JavaScript操作Select下拉列表框的方法,旨在满足特定场景...
本文将详细讲解如何使用jQuery实现无限级联动下拉选择插件,以及涉及的相关技术与实践。 首先,我们要理解"无限级联动下拉选择插件"的概念。在网页设计中,联动下拉选择通常用于实现两个或更多下拉菜单之间的关联。...
"select下拉列表显示图片内容"就是这样一个特例,它通过一些技术手段实现了在下拉选项中嵌入图片。 要实现这个效果,通常有以下几种方法: 1. **CSS和JavaScript**: 使用CSS来定制`<option>`元素的样式,并通过...
- 初始化操作:加载第一级select,其余下拉列表默认为空或隐藏。 - 事件监听:监听第一级select的选项变化。 - 数据处理:根据选中的值,动态从数据源中获取下一级菜单的选项。 - 动态生成下拉列表:使用从数据源中...
二级联动的核心在于监听第一个下拉列表的`onChange`事件,当用户在第一个下拉列表中选择一个选项时,触发该事件,通过JavaScript获取当前选中的索引或值,然后根据这个信息动态地更新第二个下拉列表的选项。...
3. JavaScript 或 jQuery:实现动态交互,监听鼠标事件,控制下拉菜单的显示与隐藏,以及处理无限级分类的逻辑。 三、关键代码实现 1. HTML 骨架: ```html <li><a href="#">菜单1 <li><a href="#">子菜单1-1...
本主题将探讨如何利用jQuery实现一个特定的功能——“select下拉列表根据radio选项级联”。这个功能常用于创建动态表单,其中,用户选择一个radio按钮后,相关的select下拉列表会自动更新其选项,以提供与所选radio...
在JavaScript中,获取下拉列表(也称为选择框或`<select>`元素)的值是一项常见的任务,特别是在处理用户输入和交互时。本篇博文中,我们将深入探讨如何有效地实现这一功能。 首先,我们需要理解HTML中的`<select>`...
本文将详细介绍如何使用JavaScript实现全国城市三级联动下拉列表,并结合提供的资源进行解析。 首先,理解“三级联动”的概念:当用户在一级下拉列表(如省份)中选择一个选项时,二级下拉列表(如城市)会根据所选...
3. JavaScript: JavaScript是实现下拉列表联动的关键,它负责监听第一个下拉框的选择变化,并根据选择值更新第二个下拉框的内容。可以使用`addEventListener`来监听`change`事件,然后使用DOM操作(如`document....
JS中Select下拉列表类支持输入模糊查询功能的知识点主要包括以下几个方面: 1. HTML结构设计:实现输入模糊查询功能的下拉列表通常包含一个输入框和一个下拉框。输入框用于用户输入查询字符,下拉框则是提供选项供...
"多选下拉列表"和"复选下拉列表"是常见的组件,用于提供用户在一组选项中进行多个选择的功能。这些组件通常用于数据筛选、配置设置或信息录入等场景。本主题将深入探讨基于jQuery的多选下拉列表插件及其应用。 1. *...
`<select>`元素用于创建一个下拉列表,而`<option>`元素则用于定义下拉列表中的选项。联动下拉菜单的基本原理是,当用户在一个下拉菜单中选择一个选项时,另一个下拉菜单的选项会根据前者的选中值动态更新。 1. **...
在网页设计中,"select级联下拉列表"是一种常见的交互元素,用于创建省市区选择、类别层级展示等场景。这种技术通常结合JavaScript(JS)、HTML5和jQuery库来实现,使得用户能够在多个下拉菜单之间进行联动选择,...