当前位置: 代码迷 >> ASP.NET >> 后台获取jS二级联动下拉框值的有关问题-
  详细解决方案

后台获取jS二级联动下拉框值的有关问题-

热度:3114   发布时间:2013-02-25 00:00:00.0
后台获取jS二级联动下拉框值的问题-------------在线等
JScript code
var _location = new Array();_location[1] = "北京";_location[2] = "天津";_location[3] = "河北";_location[4] = "山西";_location[5] = "内蒙古";_location[6] = "辽宁";_location[7] = "吉林";_location[8] = "黑龙江";_location[9] = "上海";_location[10] = "江苏";_location[11] = "浙江";_location[12] = "安徽";_location[13] = "福建";_location[14] = "江西";_location[15] = "山东";_location[16] = "河南";_location[17] = "湖北";_location[18] = "湖南";_location[19] = "广东";_location[20] = "广西";_location[21] = "海南";_location[22] = "重庆";_location[23] = "四川";_location[24] = "贵州";_location[25] = "云南";_location[26] = "西藏";_location[27] = "陕西";_location[28] = "甘肃";_location[29] = "青海";_location[30] = "宁夏";_location[31] = "新疆";_location[32] = "香港";_location[33] = "澳门";_location[34] = "台湾";var _sub_location = new Array();_sub_location[1] = new Array();_sub_location[1][1001] = "东城区";_sub_location[1][1002] = "西城区";_sub_location[1][1003] = "崇文区";_sub_location[1][1004] = "宣武区";_sub_location[1][1005] = "朝阳区";_sub_location[1][1006] = "海淀区";_sub_location[1][1007] = "丰台区";_sub_location[1][1008] = "石景山区";_sub_location[1][1009] = "门头沟区";_sub_location[1][1010] = "房山区";_sub_location[1][1011] = "通州区";

。。。。
JScript code
function bulid_select_normal(domid,data_array,def_value){        $('#'+domid).children().remove();    if(def_value == ''){        $('#'+domid).append('<option value=""  selected="selected">请选择</option>');    }else{        $('#'+domid).append('<option value="">请选择</option>');    }        $.each(data_array,function(key,val){        var s = '';        if(val != undefined){            if(key == def_value){                s = '<option value="'+key+'" checked selected="selected">'+val+'</option>';            }else{                s = '<option value="'+key+'" checked>'+val+'</option>';            }        }        $('#'+domid).append(s);    });        }function bulid_select(domid,data_array,def_value){        $('#'+domid).children().remove();            $.each(data_array,function(key,val){        var s = '';        if(val != undefined){            if(key == def_value){                s = '<option value="'+key+'" checked selected="selected">'+val+'</option>';            }else{                s = '<option value="'+key+'" checked>'+val+'</option>';            }        }        $('#'+domid).append(s);    });        }function getProvince(pro_array, city_array, data,city){    var res = '';    $.each(pro_array,function(key,val){            if(data == key){            if(city == 'city'){                                res = '';                return false;            }else{                res = key;                return false;            }        }        if(city_array[key] != undefined){            $.each(city_array[key],function(k,v){                if (v != undefined){                    if(data == k){                        if(city == 'city'){                            res = k;                            return false;                        }else{                            res = key;                            return false;                        }                    }                }            });        }    });        return res;}function bulid_second(firstid,secondid,first_array,second_array,def_value){        var first_val = $('#'+firstid).val();    $('#'+secondid).children().remove();    if(first_val == '' || def_value == ''){        $('#'+secondid).append('<option value=""  selected="selected">请选择</option>');    }else{        $('#'+secondid).append('<option value="">请选择</option>');    }    if(first_val == '') return ;        $.each(second_array[first_val],function(key,val){        var s = '';                if(val != undefined){            if(key == def_value){                s = '<option value="'+key+'" checked selected="selected">'+val+'</option>';            }else{                s = '<option value="'+key+'" checked>'+val+'</option>';            }        }        $('#'+secondid).append(s);    });        }function getShowByVal(spanid,data_array,def_value){    var res = '';        $.each(data_array,function(key,val){        var s = '';        if(val != undefined){            if(key == def_value){                res = val;                return false;            }        }            });        $('#'+spanid)(res);}
  相关解决方案