首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

省市联动效能的vm+js代码 其他相关的Select联动都可以用

2012-06-28 
省市联动功能的vm+js代码 其他相关的Select联动都可以用HTML:?select value0 selectedselected dis

省市联动功能的vm+js代码 其他相关的Select联动都可以用

HTML:

?

<select value="0" selected="selected" disabled="disabled"><option>请选择城市</option></select>
?? ??? ??? ??? ??? ???? #foreach($province in $provinceList)
?? ??? ??? ??? ??? ??? ??? ??? <select style="display:none" >
?? ??? ??? ??? ??? ??? ??? ??? ??? ?? #foreach($city in $cityList)
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ???? #if($city.provinceId==$province.id)
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? <option value="$city.id">$city.city</option>
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? #end
?? ??? ??? ??? ??? ???? #end

</select>


JS:

?

/**
? * @function 省市联动功能
? */
?$(".selections .selPro").change(function(){
???? $(" .selections .selPro option").each(function(i,o){
??? ??? ?if($(this).attr("value")==0){
??? ??? ? $(" .selections .selCity").eq(0).attr("disabled","disabled");
??? ??? ?}
???????? if($(this).attr("selected"))
???????? {
??????? ??? ? $(".selections .selCity").hide();
??????? ??? ? $(".selections .selCity[selected=selected]").removeAttr("selected");
??????? ??? ? $(".selections .selCity").eq(i).show();
??????? ??? ? $(".selections .selCity").eq(i).attr("selected","selected");
???????? }
???? });
?});
?$(".selections .selPro").change();

?

?

希望对大家有帮助~

热点排行