導航:首頁 > 編程語言 > 省份城市js

省份城市js

發布時間:2023-09-02 04:00:49

1. javascript實現點擊省份出現城市功能

使用jq吧,很多操作可以簡化,先引入jq文件
省份option的value寫為省份的標示,就是省份和城市關聯的欄位
<script>

$(function(){
$('#dorp1').change(function(){
var province = $(this).val();
$.get("/控制器名/請求的方法名", {'id':province}, function(ret){
// ret是請求方法的返回值,在這里就是通過省份查到的城市數組
var city = '';

$.each(ret, function(i, o){
city += "<option value=" + o.城市id + ">" + o.城市名 + "<option>";

})

$("#dorp2").empty().append(city);

})

});

})
</script>

2. 省份與城市的二級級聯 用javascript實現

給你一個三級聯動,09年最新版的

<!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>
</head>

<body>

<select id="province" onchange="setCity(this.value);getArea()" name="province">
<option value="" selected="selected">請選擇</option>
</select>

<select id="city" onchange="setCounty(this.value);getArea()" name="city" style="display:;">
<option value="" selected="selected">請選擇</option>
</select>

<select id="county" name="county" onchange="getArea()" style="display:;">
<option value="" selected="selected">請選擇</option>
</select>

<input type="text" name="area" id="area" value="222426" onchange="setArea();"/>
<input type="button" value="轉" onclick="setArea();" />

<script type="text/javascript">

var areaData = "110000|北京市,110100|市轄區,110101|東城區,110102|西城區,110103|崇文區,110104|宣武區,110105|朝陽區,110106|豐台區,110107|石景山區,110108|海淀區,110109|門頭溝區,110111|房山區,110112|通州區,110113|順義區,110114|昌平區,110115|大興區,110116|懷柔區,110117|平谷區,110200|縣,110228|密雲縣,110229|延慶縣,120000|天津市,120100|市轄區,120101|和平區,120102|河東區,120103|河西區,120104|南開區,120105|河北區,120106|紅橋區,120107|塘沽區,120108|漢沽區,120109|大港區,120110|東麗區,120111|西青區,120112|津南區,120113|北辰區,120114|武清區,120115|寶坻區,120200|縣,120221|寧河縣,120223|靜海縣,120225|薊縣,130000|河北省,130100|石家莊市,130101|市轄區,130102|長安區,130103|橋東區,130104|橋西區,130105|新華區,130107|井陘礦區,130108|裕華區,130121|井陘縣,130123|正定縣,130124|欒城縣,130125|行唐縣,130126|靈壽縣,130127|高邑縣,130128|深澤縣,130129|贊皇縣,130130|無極縣,130131|平山縣,130132|元氏縣,130133|趙縣,130181|辛集市,130182|藁城市,130183|晉州市,130184|新樂市,130185|鹿泉市,130200|唐山市,130201|市轄區,130202|路南區,130203|路北區,130204|古冶區,130205|開平區,130207|豐南區,130208|豐潤區,130223|灤縣,130224|灤南縣,130225|樂亭縣,130227|遷西縣,130229|玉田縣,130230|唐海縣,130281|遵化市,130283|遷安市,130300|秦皇島市,130301|市轄區,130302|海港區,130303|山海關區,130304|北戴河區,130321|青龍滿族自治縣,130322|昌黎縣,130323|撫寧縣,130324|盧龍縣,130400|邯鄲市,130401|市轄區,130402|邯山區,130403|叢台區,130404|復興區,130406|峰峰礦區,130421|邯鄲縣,130423|臨漳縣,130424|成安縣,130425|大名縣,130426|涉縣,130427|磁縣,130428|肥鄉縣,130429|永年縣,130430|邱縣,130431|雞澤縣,130432|廣平縣,130433|館陶縣,130434|魏縣,130435|曲周縣,130481|武安市,130500|邢台市,130501|市轄區,130502|橋東區,130503|橋西區,130521|邢台縣,130522|臨城縣,130523|內丘縣,130524|柏鄉縣,130525|隆堯縣,130526|任縣,130527|南和縣,130528|寧晉縣,130529|巨鹿縣,130530|新河縣,130531|廣宗縣,130532|平鄉縣,130533|威縣,130534|清河縣,130535|臨西縣,130581|南宮市,130582|沙河市,130600|保定市,130601|市轄區,130602|新市區,130603|北市區,130604|南市區,130621|滿城縣,130622|清苑縣,130623|淶水縣,130624|阜平縣,130625|徐水縣,130626|定興縣,130627|唐縣,130628|高陽縣,130629|容城縣,130630|淶源縣,130631|望都縣,130632|安新縣,130633|易縣,130634|曲陽縣,130635|蠡縣,130636|順平縣,130637|博野縣,130638|雄縣,130681|涿州市,130682|定州市,130683|安國市,130684|高碑店市,130700|張家口市,130701|市轄區,130702|橋東區,130703|橋西區,130705|宣化區,130706|下花園區,130721|宣化縣,130722|張北縣,130723|康保縣,130724|沽源縣,130725|尚義縣,130726|蔚縣,130727|陽原縣,130728|懷安縣,130729|萬全縣,130730|懷來縣,130731|涿鹿縣,130732|赤城縣,130733|崇禮縣,130800|承德市,130801|市轄區,130802|雙橋區,130803|雙灤區,130804|鷹手營子礦區,130821|承德縣,130822|興隆縣,130823|平泉縣,130824|灤平縣,130825|隆化縣,130826|豐寧滿族自治縣,130827|寬城滿族自治縣,130828|圍場滿族蒙古族自治縣,130900|滄州市,130901|市轄區,130902|新華區,130903|運河區,130921|滄縣,130922|青縣,130923|東光縣,130924|海興縣,130925|鹽山縣,130926|肅寧縣,130927|南皮縣,130928|吳橋縣,130929|獻縣,130930|孟村回族自治縣,130981|泊頭市,130982|任丘市,130983|黃驊市,130984|河間市,131000|廊坊市,131001|市轄區,131002|安次區,131003|廣陽區,131022|固安縣,131023|永清縣,131024|香河縣,131025|大城縣,131026|文安縣,131028|大廠回族自治縣,131081|霸州市,131082|三河市,131100|衡水市,131101|市轄區,131102|桃城區,131121|棗強縣,131122|武邑縣,131123|武強縣,131124|饒陽縣,131125|安平縣,131126|故城縣,131127|景縣,131128|阜城縣,131181|冀州市,131182|深州市,140000|山西省,140100|太原市,140101|市轄區,140105|小店區,140106|迎澤區,140107|杏花嶺區,140108|尖草坪區,140109|萬柏林區,140110|晉源區,140121|清徐縣,140122|陽曲縣,140123|婁煩縣,140181|古交市,140200|大同市,140201|市轄區,140202|城區,140203|礦區,140211|南郊區,140212|新榮區,140221|陽高縣,140222|天鎮縣,140223|廣靈縣,140224|靈丘縣,140225|渾源縣,140226|左雲縣,140227|大同縣,140300|陽泉市,140301|市轄區,140302|城區,140303|礦區,140311|郊區,140321|平定縣,140322|盂縣,140400|長治市,140401|市轄區,140402|城區,140411|郊區,140421|長治縣,140423|襄垣縣,140424|屯留縣,140425|平順縣,140426|黎城縣,140427|壺關縣,140428|長子縣,140429|武鄉縣,140430|沁縣,140431|沁源縣,140481|潞城市,140500|晉城市,140501|市轄區,140502|城區,140521|沁水縣,140522|陽城縣,140524|陵川縣,140525|澤州縣,140581|高平市,140600|朔州市,140601|市轄區,140602|朔城區,140603|平魯區,140621|山陰縣,140622|應縣,140623|右玉縣,140624|懷仁縣,140700|晉中市,140701|市轄區,140702|榆次區,140721|榆社縣,140722|左權縣,140723|和順縣,140724|昔陽縣,140725|壽陽縣,140726|太谷縣,140727|祁縣,140728|平遙縣,140729|靈石縣,140781|介休市,140800|運城市,140801|市轄區,140802|鹽湖區,140821|臨猗縣,140822|萬榮縣,140823|聞喜縣,140824|稷山縣,140825|新絳縣,140826|絳縣,140827|垣曲縣,140828|夏縣,140829|平陸縣,140830|芮城縣,140881|永濟市,140882|河津市,140900|忻州市,140901|市轄區,140902|忻府區,140921|定襄縣,140922|五台縣,140923|代縣,140924|繁峙縣,140925|寧武縣,140926|靜樂縣,140927|神池縣,140928|五寨縣,140929|岢嵐縣,140930|河曲縣,140931|保德縣,140932|偏關縣,140981|原平市,141000|臨汾市,141001|市轄區,141002|堯都區,11|曲沃縣,12|翼城縣,13|襄汾縣,14|洪洞縣,15|古縣,16|安澤縣,17|浮山縣,18|吉縣,19|鄉寧縣,141030|大寧縣,141031|隰縣,141032|永和縣,141033|蒲縣,141034|汾西縣,141081|侯馬市,141082|霍州市,141100|呂梁市,141101|市轄區,141102|離石區,141121|文水縣,141122|交城縣,141123|興縣,141124|臨縣,141125|柳林縣,141126|石樓縣,141127|嵐縣,141128|方山縣,141129|中陽縣,141130|交口縣,141181|孝義市,141182|汾陽市,150000|內蒙古自治區,150100|呼和浩特市,150101|市轄區,150102|新城區,150103|回民區,150104|玉泉區,150105|賽罕區,150121|土默特左旗,150122|托克托縣,150123|和林格爾縣,150124|清水河縣,150125|武川縣,150200|包頭市,150201|市轄區,150202|東河區,150203|昆都侖區,150204|青山區,150205|石拐區,150206|白雲礦區,150207|九原區,150221|土默特右旗,150222|固陽縣,150223|達爾罕茂明安聯合旗,150300|烏海市,150301|市轄區,150302|海勃灣區,150303|海南區,150304|烏達區,150400|赤峰市,150401|市轄區,150402|紅山區,150403|元寶山區,150404|松山區,150421|阿魯科爾沁旗,150422|巴林左旗,150423|巴林右旗,150424|林西縣,150425|克什克騰旗,150426|翁牛特旗,150428|喀喇沁旗,150429|寧城縣,150430|敖漢旗,150500|通遼市,150501|市轄區,150502|科爾沁區,150521|科爾沁左翼中旗,150522|科爾沁左翼後旗,150523|開魯縣,150524|庫倫旗,150525|奈曼旗,150526|扎魯特旗,150581|霍林郭勒市,150600|鄂爾多斯市,150601|市轄區,150602|東勝區,150621|達拉特旗,150622|准格爾旗,150623|鄂托克前旗,150624|鄂托克旗,150625|杭錦旗,150626|烏審旗,150627|伊金霍洛旗,150700|呼倫貝爾市,150701|市轄區,150702|海拉爾區,150721|阿榮旗,150722|莫力達瓦達斡爾族自治旗,150723|鄂倫春自治旗,150724|鄂溫克族自治旗,150725|陳巴爾虎旗,150726|新巴爾虎左旗,150727|新巴爾虎右旗,150781|滿洲里市,150782|牙克石市,150783|扎蘭屯市,150784|額爾古納市,150785|根河市,150800|巴彥淖爾市,150801|市轄區,150802|臨河區,150821|五原縣,150822|磴口縣,150823|烏拉特前旗,150824|烏拉特中旗,150825|烏拉特後旗,150826|杭錦後旗,150900|烏蘭察布市,150901|市轄區,150902|集寧區,150921|卓資縣,150922|化德縣,150923|商都縣,150924|興和縣,150925|涼城縣,150926|察哈爾右翼前旗,150927|察哈爾右翼中旗,150928|察哈爾右翼後旗,150929|四子王旗,150981|豐鎮市,152200|興安盟,152201|烏蘭浩特市,152202|阿爾山市,152221|科爾沁右翼前旗,152222|科爾沁右翼中旗,152223|扎賚特旗,152224|突泉縣,152500|錫林郭勒盟,152501|二連浩特市,152502|錫林浩特市,152522|阿巴嘎旗,152523|蘇尼特左旗,152524|蘇尼特右旗,152525|東烏珠穆沁旗,152526|西烏珠穆沁旗,152527|太僕寺旗,152528|鑲黃旗,152529|正鑲白旗,152530|正藍旗,152531|多倫縣,152900|阿拉善盟,152921|阿拉善左旗,152922|阿拉善右旗,152923|額濟納旗,210000|遼寧省,210100|沈陽市,210101|市轄區,210102|和平區,210103|瀋河區,210104|大東區,210105|皇姑區,210106|鐵西區,210111|蘇家屯區,210112|東陵區,210113|沈北新區,210114|於洪區,210122|遼中縣,210123|康平縣,210124|法庫縣,210181|新民市,210200|大連市,210201|市轄區,210202|中山區,210203|西崗區,210204|沙河口區,210211|甘井子區,210212|旅順口區,210213|金州區,210224|長海縣,210281|瓦房店市,210282|普蘭店市,210283|庄河市,210300|鞍山市,210301|市轄區,210302|鐵東區,210303|鐵西區,210304|立山區,210311|千山區,210321|台安縣,210323|岫岩滿族自治縣,210381|海城市,210400|撫順市,210401|市轄區,210402|新撫區,210403|東洲區,210404|望花區,210411|順城區,210421|撫順縣,210422|新賓滿族自治縣,210423|清原滿族自治縣,210500|本溪市,210501|市轄區,210502|平山區,210503|溪湖區,210504|明山區,210505|南芬區,210521|本溪滿族自治縣,210522|桓仁滿族自治縣,210600|丹東市,210601|市轄區,210602|元寶區,210603|振興區,210604|振安區,210624|寬甸滿族自治縣,210681|東港市,210682|鳳城市,210700|錦州市,210701|市轄區,210702|古塔區,210703|凌河區,210711|太和區,210726|黑山縣,210727|義縣,210781|凌海市,210782|北鎮市,210800|營口市,210801|市轄區,210802|站前區,210803|西市區,210804|鮁魚圈區,210811|老邊區,210881|蓋州市,210882|大石橋市,210900|阜新市,210901|市轄區,210902|海州區,210903|新邱區,210904|太平區,210905|清河門區,210911|細河區,210921|阜新蒙古族自治縣,210922|彰武縣,211000|遼陽市,211001|市轄區,211002|白塔區,211003|文聖區,211004|宏偉區,211005|弓長嶺區,211011|太子河區,211021|遼陽縣,211081|燈塔市,211100|盤錦市,211101|市轄區,211102|雙檯子區,211103|興隆台區,211121|大窪縣,211122|盤山縣,211200|鐵嶺市,211201|市轄區,211202|銀州區,211204|清河區,211221|鐵嶺縣,211223|西豐縣,211224|昌圖縣,211281|調兵山市,211282|開原市,00|朝陽市,01|市轄區,02|雙塔區,03|龍城區,21|朝陽縣,22|建平縣,24|喀喇沁左翼蒙古族自治縣,81|北票市,82|凌源市,211400|葫蘆島市,211401|市轄區,211402|連山區,211403|龍港區,211404|南票區,211421|綏中縣,211422|建昌縣,211481|興城市,220000|吉林省,220100|長春市,220101|市轄區,220102|南關區,220103|寬城區,220104|朝陽區,220105|二道區,220106|綠園區,220112|雙陽區,220122|農安縣,220181|九台市,220182|榆樹市,220183|德惠市,220200|吉林市,220201|市轄區,220202|昌邑區,220203|龍潭區,220204|船營區,220211|豐滿區,220221|永吉縣,220281|蛟河市,220282|樺甸市,220283|舒蘭市,220284|磐石市,220300|四平市,220301|市轄區,220302|鐵西區,220303|鐵東區,220322|梨樹縣,220323|伊通滿族自治縣,220381|公主嶺市,220382|雙遼市,220400|遼源市,220401|市轄區,220402|龍山區,220403|西安區,220421|東豐縣,220422|東遼縣,220500|通化市,220501|市轄區,220502|東昌區,220503|二道江區,220521|通化縣,220523|輝南縣,220524|柳河縣,220581|梅河口市,220582|集安市,220600|白山市,220601|市轄區,220602|八道江區,220605|江源區,220621|撫松縣,220622|靖宇縣,220623|長白朝鮮族自治縣,220681|臨江市,220700|松原市,220701|市轄區,220702|寧江區,220721|前郭爾羅斯蒙古族自治縣,220722|長嶺縣,220723|乾安縣,220724|扶余縣,220800|白城市,220801|市轄區,220802|洮北區,220821|鎮賚縣,220822|通榆縣,220881|洮南市,220882|大安市,222400|延邊朝鮮族自治州,222401|延吉市,222402|圖們市,222403|敦化市,222404|琿春市,222405|龍井市,222406|和龍市,222424|汪清縣,222426|安圖縣,230000|黑龍江省,230100|哈爾濱市,230101|市轄區,230102|道里區,230103|南崗區,230104|道外區,230108|平房區,230109|松北區,230110|香坊區,230111|呼蘭區,230112|阿城區,230123|依蘭縣,230124|方正縣,230125|賓縣,230126|巴彥縣,230127|木蘭縣,230128|通河縣,230129|延壽縣,230182|雙城市,230183|尚志市,230184|五常市,230200|齊齊哈爾市,230201|市轄區,230202|龍沙區,230203|建華區,230204|鐵鋒區,230205|昂昂溪區,230206|富拉爾基區,230207|碾子山區,230208|梅里斯達斡爾族區,230221|龍江縣,230223|依安縣,230224|泰來縣,230225|甘南縣,230227|富裕縣,230229|克山縣,230230|克東縣,230231|拜泉縣,230281|訥河市,230300|雞西市,230301|市轄區,230302|雞冠區,230303|恆山區,230304|滴道區,230305|梨樹區,230306|城子河區,230307|麻山區,230321|雞東縣,230381|虎林市,230382|密山市,230400|鶴崗市,230401|市轄區,230402|向陽區,230403|工農區,230404|南山區,230405|興安區,230406|東山區,230407|興山區,230421|蘿北縣,230422|綏濱縣,230500|雙鴨山市,230501|市轄區,230502|尖山區,230503|嶺東區,230505|四方台區,230506|寶山區,230521|集賢縣,230522|友誼縣,230523|寶清縣,230524|饒河縣,230600|大慶市,230601|市轄區,230602|薩爾圖區,230603|龍鳳區,230604|讓胡路區,230605|紅崗區,230606|大同區,230621|肇州縣,230622|肇源縣,230623|林甸縣,230624|杜爾伯特蒙古族自治縣,230700|伊春市,230701|市轄區,230702|伊春區,230703|南岔區,230704|友好區,230705|西林區,230706|翠巒區,230707|新青區,230708|美溪區,230709|金山屯區,230710|五營區,230711|烏馬河區,230712|湯旺河區,230713|帶嶺區,230714|烏伊嶺區,230715|紅星區,230716|上甘嶺區,230722|嘉蔭縣,230781|鐵力市,230800|佳木斯市,230801|市轄區,230803|向陽區,230804|前進區,230805|東風區,230811|郊區,230822|樺南縣,230826|樺川縣,230828|湯原縣,230833|撫遠縣,230881|同江市,230882|富錦市,230900|七台河市,230901|市轄區,230902|新興區,230903|桃山區,230904|茄子河區,230921|勃利縣,231000|牡丹江市,231001|市轄區,231002|東安區,231003|陽明區,231004|愛民區,231005|西安區,231024|東寧縣,231025|林口縣,231081|綏芬河市,231083|海林市,231084|寧安市,231085|穆棱市,231100|黑河市,231101|市轄區,231102|愛輝區,231121|嫩江縣,231123|遜克縣,231124|孫吳縣,231181|北安市,231182|五大連池市,231200|綏化市,231201|市轄區,231202|北林區,231221|望奎縣,231222|蘭西縣,231223|青岡縣,231224|慶安縣,231225|明水縣,231226|綏棱縣,231281|安達市,231282|肇東市,231283|海倫市,232700|大興安嶺地區,232721|呼瑪縣,232722|塔河縣,232723|漠河縣,310000|上海市,310100|市轄區,310101|黃浦區,310103|盧灣區,310104|徐匯區,310105|長寧區,310106|靜安區,310107|普陀區,310108|閘北區,310109|虹口區,310110|楊浦區,310112|閔行區,310113|寶山區,310114|嘉定區,310115|浦東新區,310116|金山區,310117|松江區,310118|青浦區,310119|南匯區,310120|奉賢區,310200|縣,310230|崇明縣,320000|江蘇省,320100|南京市,320101|市轄區,320102|玄武區,320103|白下區,320104|秦淮區,320105|建鄴區,320106|鼓樓區,320107|下關區,320111|浦口區,320113|棲霞區,320114|雨花台區,320115|江寧區,320116|六合區,320124|溧水縣,320125|高淳縣,320200|無錫市,320201|市轄區,320202|崇安區,320203|南長區,320204|北塘區,320205|錫山區,320206|惠山區,320211|濱湖區,320281|江陰市,320282|宜興市,320300|徐州市,320301|市轄區,320302|鼓樓區,320303|雲龍區,320304|九里區,320305|賈汪區,320311|泉山區,320321|豐縣,320322|沛縣,320323|銅山縣,320324|睢寧縣,320381|新沂市,320382|邳州市,320400|常州市,320401|市轄區,320402|天寧區,320404|鍾樓區,320405|戚墅堰區,320411|新北區,320412|武進區,320481|溧陽市,320482|金壇市,320500|蘇州市,320501|市轄區,320502|滄浪區,320503|平江區,320504|金閶區,320505|虎丘區,320506|吳中區,320507|相城區,320581|常熟市,320582|張家港市,320583|崑山市,320584|吳江市,320585|太倉市,320600|南通市,320601|市轄區,320602|崇川區,320611|港閘區,320621|海安縣,320623|如東縣,320681|啟東市,320682|如皋市,320683|通州市,320684|海門市,320700|連雲港市,320701|市轄區,320703|連雲區,320705|新浦區,320706|海州區,320721|贛榆縣,320722|東海縣,320723|灌雲縣,320724|灌南縣,320800|淮安市,320801|市轄區,320802|清河區,320803|楚州區,320804|淮陰區,320811|清浦區,320826|漣水縣,320829|洪澤縣,320830|盱眙縣,320831|金湖縣,320900|鹽城市,320901|市轄區,320902|亭湖區,320903|鹽都區,320921|響水縣,320922|濱海縣,320923|阜寧縣,320924|射陽縣,320925|建湖縣,320981|東台市,320982|大豐市,321000|揚州市,321001|市轄區,321002|廣陵區,321003|邗江區,321011|維揚區,321023|寶應縣,321081|儀征市,321084|高郵市,321088|江都市,321100|鎮江市,321101|市轄區,321102|京口區,321111|潤州區,321112|丹徒區,321181|丹陽市,321182|揚中市,321183|句容市,321200|泰州市,321201|市轄區,321202|海陵區,321203|高港區,321281|興化市,321282|靖江市,321283|泰興市,321284|姜堰市,321300|宿遷市,321301|市轄區,321302|宿城區,321311|宿豫區,321322|沭陽縣,321323|泗陽縣,321324|泗洪縣,330000|浙江省,330100|杭州市,330101|市轄區,330102|上城區,330103|下城區,330104|江干區,330105|拱墅區,330106|西湖區,330108|濱江區,330109|蕭山區,330110|餘杭區,330122|桐廬縣,330127|淳安縣,330182|建德市,330183|富陽市,330185|臨安市,330200|寧波市,330201|市轄區,330203|海曙區,330204|江東區,330205|江北區,330206|北侖區,330211|鎮海區,330212|鄞州區,330225|象山縣,330226|寧海縣,330281|餘姚市,330282|慈溪市,330283|奉化市,330300|溫州市,330301|市轄區,330302|鹿城區,330303|龍灣區,330304|甌海區,330322|洞頭縣,330324|永嘉縣,330326|平陽縣,330327|蒼南縣,330328|文成縣,330329|泰順縣,330381|瑞安市,330382|樂清市,330400|嘉興市,330401|市轄區,330402|南湖區,330411|秀洲區,330421|嘉善縣,330424|海鹽縣,330481|海寧市,330482|平湖市,330483|桐鄉市,330500|湖州市,330501|市轄區,330502|吳興區,330503|南潯區,330521|德清縣,330522|長興縣,330523|安吉縣,330600|紹興市,330601|市轄區,330602|越城區,330621|紹興縣,330624|新昌縣,330681|諸暨市,330682|上虞市,330683|嵊州市,330700|金華市,330701|市轄區,330702|婺城區,330703|金東區,330723|武義縣,330726|浦江縣,330727|磐安縣,330781|蘭溪市,330782|義烏市,330783|東陽市,330784|永康市,330800|衢州市,330801|市轄區,330802|柯城區,330803|衢江區,330822|常山縣,330824|開化縣,330825|龍游縣,330881|江山市,330900|舟山市,330901|市轄區,330902|定海區,330903|普陀區,330921|岱山縣,330922|嵊泗縣,331000|台州市,331001|市轄區,331002|椒江區,331003|黃岩區,331004|路橋區,331021|玉環縣,331022|三門縣,331023|天台縣,331024|仙居縣,331081|溫嶺市,331082|臨海市,331100|麗水市,331101|市轄區,331102|蓮都區,331121|青田縣,331122|縉雲縣,331123|遂昌縣,331124|松陽縣,331125|雲和縣,331126|慶元縣,331127|景寧畲族自治縣,331181|龍泉市,340000|安徽省,340100|合肥市,340101|市轄區,340102|瑤海區,340103|廬陽區,340104|蜀山區,340111|包河區,340121|長豐縣,340122|肥東縣,340123|肥西縣,340200|蕪湖市,340201|市轄區,340202|鏡湖區,340203|弋江區,340207|鳩江區,340208|三山區,340221|蕪湖縣,340222|繁昌縣,340223|南陵縣,340300|蚌埠市,340301|市轄區,340302|龍子湖區,340303|蚌山區,340304|禹會區,340311|淮上區,340321|懷遠縣,340322|五河縣,340323|固鎮縣,340400|淮南市,340401|市轄區,340402|大通區,340403|田家庵區,340404|謝家集區,340405|八公山區,340406|潘集區,340421|鳳台縣,340500|馬鞍山市,340501|市轄區,340502|金家莊區,340503|花山區,340504|雨山區,340521|當塗縣,340600|淮北市,340601|市轄區,340602|杜集區,340603|相山區,340604|烈山區,340621|濉溪縣,340700|銅陵市,340701|市轄區,340702|銅官山區,340703|獅子山區,340711|郊區,340721|銅陵縣,340800|安慶市,340801|市轄區,340802|迎江區,340803|大觀區,340811|宜秀區,340822|懷寧縣,340823|樅陽縣,340824|潛山縣,340825|太湖縣,340826|宿松縣,340827|望江縣,340828|岳西縣,340881|桐城市,341000|黃山市,341001|市轄區,341002|屯溪區,341003|黃山區,341004|徽州區,31|歙縣,32|休寧縣,33|黟縣,34|祁門縣,341100|滁州市,341101|市轄區,341102|琅琊區,341103|南譙區,341122|來安縣,341124|全椒縣,341125|定遠縣,341126|鳳陽縣,341181|天長市,341182|明光市,341200|阜陽市,341201|市轄區,341202|潁州區,341203|潁東區,341204|潁泉區,341221|臨泉縣,341222|太和縣,341225|阜南縣,341226|潁上縣,341282|界首市,341300|宿州市,341301|市轄區,341302|埇橋區,341321|碭山縣,341322|蕭縣,341323|靈璧縣,341324|泗縣,341400|巢湖

3. 29_用js實現一個省市級聯效果

(1)var provs={},存儲省市的json結構數據。

(2)function loadProv() {},此函數實現了初始化頁面載入數據的功能。

(3)var prov = document.getElementById("prov"),獲取存放省份的select下拉菜單。

(4)for (var key in provs),遍歷json結構數據。

(5)var provName = key,獲取省份的名稱。

(6)var optProv = document.createElement("option"),創建一個option元素對象。

(7)optProv.value = provName,設置option元素的value屬性值。

(8)optProv.innerText = provName,設置option顯示的文本內容。

(9)prov.appendChild(optProv),將option元素添加到select下拉菜單。

(10)function provChange() {},作為onchange事件處理函數。

(11)var prov = document.getElementById("prov"),獲取省份下拉菜單。

(12)var city = document.getElementById("city"),獲取城市下拉菜單。

(13)var provName = prov.value,獲取當前選中的省份的value值。

(14)if (provName == "none") {

city.style.display = "none";

return;

},如果值等於none,說明選中的是第一項,那麼城市下拉菜單還是具有隱藏狀態,並跳出函數。

(15)else {

city.style.display = "";

},否則的話顯示出城市下拉菜單,默認狀態它是隱藏的。

(16)var citys = provs[provName],獲取城市,citys是個數組。

(17)for (var index = city.childNodes.length - 1; index >= 0; index--) {

var child = city.childNodes[index];

city.removeChild(child);

},遍歷城市下拉菜單下的option元素,然後刪除這些元素。

之所以清空就是為了防止當再次載入的時候出現累加情況。

(18)for (var index = 0; index < citys.length; index++) {},遍歷數組中的元素,也就是城市。

(19)var optCity = document.createElement("option"),創建option元素。

(20)optCity.value = citys[index],設置option元素的value值。

(21)optCity.innerText = citys[index],設置option元素的文本內容。

(22)city.appendChild(optCity),將option元素添加select下拉菜單。

數據表形式數據

json形式數據

4. bootstrap-select.js 怎麼聯動改變,例如:省份,城市二級聯動。

「bootstrap-select.js 」聯動改變方式如下:

1、多選效果

閱讀全文

與省份城市js相關的資料

熱點內容
90版本升級不送 瀏覽:186
工具箱英文 瀏覽:382
南翔嘉定編程課哪裡好 瀏覽:853
win10改變文件格式 瀏覽:475
linux中的物理地址和虛擬地址 瀏覽:493
有哪些app可以接游戲訂單 瀏覽:472
蘋果硬碟數據恢復要多少錢 瀏覽:394
js綁定下拉框資料庫數據 瀏覽:448
cad文件怎麼復制到另一個文件里邊 瀏覽:858
dxp鑽孔文件 瀏覽:631
iphone大悅城換機 瀏覽:538
找結婚對象上什麼網站 瀏覽:974
學生信息管理系統程序設計報告 瀏覽:640
微信文件怎麼刪除怎麼恢復 瀏覽:407
編程程序怎麼復制 瀏覽:467
文件更改 瀏覽:327
冰點文件路徑 瀏覽:730
軟體一點開文件就關閉 瀏覽:88
網路如何把人捧紅 瀏覽:961
軟體傳輸文件 瀏覽:184

友情鏈接