1. [代ç ]æ°å¢éæ©åå¸
$(function(){
$("#province").cityCasCade("#city").cityCasCade('select','æ²³åç');
//or
$("#province").cityCasCade("#city").cityCasCade('select','æ²³åç','å¼å°å¸');
}
/**
* java diqye
* åå¸æ°æ®æ¶ä»ç½ä¸Copyç
* 级èåè½ä¹æ¯åèç½ä¸å·²å好çæè·¯
* å°è£
ææ件为äºä»¥å使ç¨æ¹ä¾¿
* add å¢å éä¸åå¸æ¹æ³select
*/
(function($){
$.fn.cityCasCade = function(operation,province,city){
var selectCity=null,params=null,overparams=null;
if(typeof operation == "string"){
if(operation == "select"){
if(province){
$(this).find("option").each(function(){
if($(this).val()==province){
this.selected=true;
$(this).change();
if(city){
$($.fn.cityCascadeParam.selectCity).find("option").each(function(){
if($(this).val()==city){
this.selected=true;
$(this).change();
}
});
}
}
});
}
return $(this);
}
selectCity=operation;
}
else{
if(operation.selector)selectCity=operation.selector;
if(operation.overide&&operation.data)overparams=operation.data;
else params=operation.data;
}
$.fn.cityCascadeParam ={};
$.fn.cityCascadeParam.data = _provinces_;
$.fn.cityCascadeParam.selectCity = null;
if(selectCity) $.fn.cityCascadeParam.selectCity=selectCity;
else throw "åå¸éæ©å¨ä¸è½ä¸ºç©º";
$.fn.cityCascadeParam.cityValue= $($.fn.cityCascadeParam.selectCity+":first").val();
$.fn.cityCascadeParam.cityText= $($.fn.cityCascadeParam.selectCity+":first").text();
if(overparams)$.fn.cityCascadeParam.data=overparams;
else $.extend($.fn.cityCascadeParam.data, params);
$.fn.cityCascadeParam.loadProvince = function(self){
for(var p in $.fn.cityCascadeParam.data){
var opt=document.createElement("option");
opt.innerHTML=p;
opt.value=p;
self.appendChild(opt);
}
}
$.fn.cityCascadeParam.loadCity = function(parent){
var self = $($.fn.cityCascadeParam.selectCity).get(0);
if(!self) throw "æªæ¾å°åå¸ä¸ææ¡ åå¸éæ©å¨ >>" + $.fn.cityCascadeParam.selectCity;
var selectProvince=$(parent).val();
if(selectProvince in $.fn.cityCascadeParam.data){
var citys=$.fn.cityCascadeParam.data[selectProvince];
self.innerHTML="";
for(var index=0;index<citys.length;index++){
opt=document.createElement("option");
opt.innerHTML=citys[index];
opt.value=citys[index];
self.appendChild(opt);
}
}else{
self.innerHTML="";
opt=document.createElement("option");
opt.innerHTML=$.fn.cityCascadeParam.cityText;
opt.value=$.fn.cityCascadeParam.cityValue;
self.appendChild(opt);
}
}
this.each(function(){
$.fn.cityCascadeParam.loadProvince(this);
$(this).change(function(){
$.fn.cityCascadeParam.loadCity(this);
});
});
return $(this);
}
})($);
var _provinces_={åå·ç:["æé½å¸","èªè´¡å¸","ææè±å¸","泸å·å¸","å¾·é³å¸","绵é³å¸","广å
å¸","éå®å¸","å
æ±å¸","ä¹å±±å¸","åå
å¸","çå±±å¸","å®å®¾å¸","广å®å¸","è¾¾å·å¸","é
å®å¸","å·´ä¸å¸","èµé³å¸","é¿åèæç¾æèªæ²»å·","çåèæèªæ²»å·","åå±±å½æèªæ²»å·"],山西ç:["太åå¸","大åå¸","é³æ³å¸","é¿æ²»å¸","æåå¸","æå·å¸","æä¸å¸","è¿åå¸","å¿»å·å¸","临汾å¸","åæ¢å¸"],å
èå¤:["å¼å浩ç¹å¸","å
头å¸","ä¹æµ·å¸","赤峰å¸","éè¾½å¸","éå°å¤æ¯å¸","å¼ä¼¦è´å°å¸","巴彦æ·å°å¸","ä¹å
°å¯å¸å¸","å
´å®ç","é¡æéåç","é¿æåç"],è¾½å®ç:["æ²é³å¸","大è¿å¸","éå±±å¸","æ顺å¸","æ¬æºªå¸","丹ä¸å¸","é¦å·å¸","è¥å£å¸","éæ°å¸","è¾½é³å¸","çé¦å¸","éå²å¸","æé³å¸","è«è¦å²å¸"],åæç:["é¿æ¥å¸","åæå¸","åå¹³å¸","è¾½æºå¸","éåå¸","ç½å±±å¸","æ¾åå¸","ç½åå¸","延边æé²æèªæ²»å·"],é»é¾æ±ç:["åå°æ»¨å¸","é½é½åå°å¸","鸡西å¸","鹤å²å¸","åé¸å±±å¸","大åºå¸","ä¼æ¥å¸","ä½³æ¨æ¯å¸","ä¸å°æ²³å¸","ç¡ä¸¹æ±å¸","é»æ²³å¸","绥åå¸","大å
´å®å²å°åº"],ä¸æµ·:["ä¸æµ·"],æ±èç:["å京å¸","æ é¡å¸","å¾å·å¸","常å·å¸","èå·å¸","åéå¸","è¿äºæ¸¯å¸","æ·®å®å¸","çåå¸","æ¬å·å¸","éæ±å¸","æ³°å·å¸","宿è¿å¸"],æµæ±ç:["æå·å¸","å®æ³¢å¸","温å·å¸","åå
´å¸","æ¹å·å¸","ç»å
´å¸","éåå¸","è¡¢å·å¸","èå±±å¸","å°å·å¸","丽水å¸"],å®å¾½ç:["åè¥å¸","èæ¹å¸","èå å¸","æ·®åå¸","马éå±±å¸","æ·®åå¸","ééµå¸","å®åºå¸","é»å±±å¸","æ»å·å¸","éé³å¸","宿å·å¸","å·¢æ¹å¸","å
å®å¸","亳å·å¸","æ± å·å¸","宣åå¸"],ç¦å»ºç:["ç¦å·å¸","å¦é¨å¸","èç°å¸","ä¸æå¸","æ³å·å¸","æ¼³å·å¸","åå¹³å¸","é¾å²©å¸","å®å¾·å¸"],æ±è¥¿ç:["åæå¸","æ¯å¾·éå¸","è乡å¸","ä¹æ±å¸","æ°ä½å¸","é¹°æ½å¸","èµ£å·å¸","åå®å¸","å®æ¥å¸","æå·å¸","ä¸é¥¶å¸"],å±±ä¸ç:["æµåå¸","éå²å¸","æ·åå¸","æ£åºå¸","ä¸è¥å¸","çå°å¸","æ½åå¸","æµå®å¸","æ³°å®å¸","å¨æµ·å¸","æ¥ç
§å¸","è±èå¸","临æ²å¸","å¾·å·å¸","èåå¸","滨å·å¸","èæ³½å¸"],æ²³åç:["éå·å¸","å¼å°å¸","æ´é³å¸","平顶山å¸","å®é³å¸","鹤å£å¸","æ°ä¹¡å¸","ç¦ä½å¸","æ¿®é³å¸","许æå¸","漯河å¸","ä¸é¨å³¡å¸","åé³å¸","åä¸å¸","ä¿¡é³å¸","å¨å£å¸","驻马åºå¸"],æ¹åç:["æ¦æ±å¸","é»ç³å¸","åå °å¸","å®æå¸","è¥æ¨å¸","éå·å¸","èé¨å¸","åæå¸","èå·å¸","é»åå¸","å¸å®å¸","éå·å¸","æ©æ½å家æèæèªæ²»å·"],æ¹åç:["é¿æ²å¸","æ ªæ´²å¸","æ¹æ½å¸","è¡¡é³å¸","éµé³å¸","å²³é³å¸","常德å¸","å¼ å®¶çå¸","çé³å¸","é´å·å¸","æ°¸å·å¸","æåå¸","å¨åºå¸","æ¹è¥¿å家æèæèªæ²»å·"],广ä¸ç:["广å·å¸","é¶å
³å¸","æ·±å³å¸","ç æµ·å¸","æ±å¤´å¸","ä½å±±å¸","æ±é¨å¸","æ¹æ±å¸","èåå¸","èåºå¸","æ å·å¸","æ¢
å·å¸","æ±å°¾å¸","æ²³æºå¸","é³æ±å¸","æ¸
è¿å¸","ä¸èå¸","ä¸å±±å¸","æ½®å·å¸","æé³å¸","äºæµ®å¸"],广西ç:["åå®å¸","æ³å·å¸","æ¡æå¸","梧å·å¸","åæµ·å¸","é²å港å¸","é¦å·å¸","贵港å¸","çæå¸","ç¾è²å¸","è´ºå·å¸","æ²³æ± å¸","æ¥å®¾å¸","å´å·¦å¸"],æµ·åç:["æµ·å£å¸","ä¸äºå¸"],éåºå¸:["éåº"],è´µå·ç:["è´µé³å¸","å
çæ°´å¸","éµä¹å¸","å®é¡ºå¸","éä»å°åº","é»è¥¿åå¸ä¾æèæèªæ²»å·","æ¯èå°åº","é»ä¸åèæä¾æèªæ²»å·","é»åå¸ä¾æèæèªæ²»å·"],äºåç:["ææå¸","æ²éå¸","ç溪å¸","ä¿å±±å¸","æéå¸","丽æ±å¸","æè
å¸","临沧å¸","æ¥éå½æèªæ²»å·","红河åå°¼æå½æèªæ²»å·","æ山壮æèæèªæ²»å·","西åç纳å£æèªæ²»å·","大çç½æèªæ²»å·","å¾·å®å£ææ¯é¢æèªæ²»å·","ææ±åå³æèªæ²»å·","迪åºèæèªæ²»å·"],西èèªæ²»åº:["æè¨å¸","æé½å°åº","å±±åå°åº","æ¥ååå°åº","é£æ²å°åº","é¿éå°åº","æèå°åº"],é西ç:["西å®å¸","éå·å¸","å®é¸¡å¸","å¸é³å¸","æ¸åå¸","延å®å¸","æ±ä¸å¸","æ¦æå¸","å®åº·å¸","åæ´å¸"],çèç:["å
°å·å¸","å峪å
³å¸","éæå¸","ç½é¶å¸","天水å¸","æ¦å¨å¸","å¼ æå¸","å¹³åå¸","é
æ³å¸","åºé³å¸","å®è¥¿å¸","éåå¸","临å¤åæèªæ²»å·","çåèæèªæ²»å·"],éæµ·ç:["西å®å¸","æµ·ä¸å°åº","æµ·åèæèªæ²»å·","é»åèæèªæ²»å·","æµ·åèæèªæ²»å·","ææ´èæèªæ²»å·","çæ èæèªæ²»å·","海西èå¤æèæèªæ²»å·"],å®å¤èªæ²»åº:["é¶å·å¸","ç³å´å±±å¸","å´å¿ å¸","åºåå¸","ä¸å«å¸"],æ°çèªæ²»åº:["ä¹é²æ¨é½å¸","å
æçä¾å¸","åé²çªå°åº","åå¯å°åº","æååæèªæ²»å·","åå°å¡æèå¤èªæ²»å·","å·´é³éæ¥èå¤èªæ²»å·","é¿å
èå°åº","å
ååèæ¯å°å
åèªæ²»å·","åä»å°åº","åç°å°åº","ä¼çåè¨å
èªæ²»å·","å¡åå°åº","é¿åæ³°å°åº"],å°æ¹¾ç:["å°åå¸"],é¦æ¸¯ç¹åº:["é¦æ¸¯"],æ¾³é¨ç¹åº:["æ¾³é¨"],æ²³åç:["ç³å®¶åº","åå±±","秦çå²","å¼ å®¶å£","æ¿å¾·","å»å","é¯é¸","é¢å°","ä¿å®","沧å·","è¡¡æ°´"]};
温馨提示:内容为网友见解,仅供参考