标签:
二级地域选项的JS部分。
function change() {
var pro = document.getElementById(‘province‘),
scEle = document.getElementsByClassName(‘scCity‘),
gdEle = document.getElementsByClassName(‘gdCity‘),
j,
cnt;
for(var i = 0,len = pro.childNodes.length;i < len; ++i){
if(pro.childNodes[i].nodeType == 1 && pro.childNodes[i].selected){
if(pro.childNodes[i].value == ‘sc‘){
for(j = 0,cnt = scEle.length;j < cnt; ++j){
setBlock(scEle[j]);
scEle[0].selected = true;
}
for(j = 0,cnt = gdEle.length;j < cnt; ++j){
setNone(gdEle[j]);
}
break;
}
else if(pro.childNodes[i].value == ‘gd‘){
for(j = 0,cnt = scEle.length;j < cnt; ++j){
setNone(scEle[j]);
}
for(j = 0,cnt = gdEle.length;j < cnt; ++j){
setBlock(gdEle[j]);
gdEle[0].selected = true;
}
break;
}
}
}
function setNone(str){
str.style.display = "none";
}
function setBlock(str){
str.style.display = "block";
}
}
标签:
原文地址:http://www.cnblogs.com/fenghaozz/p/5405887.html