代码如下

作者:官方彩票手机投注网站-服务器运维

写这一个东西的当初的愿景是来之于和讯博客园,在新浪博客园帐号设置里面有个地段的选项,使用js写的,想把它的代码给截获下来,然而大失所望的是它的js代码压缩了,可是总的来看的中间json类型格式设计的非常好的,日常大家后台未做其余管理的json数据格式相仿以下那标准的 [{"Code":3231,"Name":"长春市"}, {"Code":3232,"Name":"吉林市}]代码如下。 假设有一万个地面,会多出几万个字符,这么浮华的做法作者想作者或然丢掉了啊, 也是由于这种主张,就写了使用.NET输出此种格式的json,以致写了基于jquery联合浮动的下拉。 首要代码如下: json代码: 复制代码 代码如下: var area = '{"city3145":"市辖区", "code3145":"3179", "city3146":"市辖区", "code3146":"3180", "city3147":"桂林市,宁德市,岳阳市,黄冈市,九江湾股市,石家庄市,呼伦贝尔市,三明市,镇江市,镇江市,玉林市", "code3147":"3181,3182,3183,3184,3185,3186,3187,3188,3189,3190,3191", "city3148":"渥太华市,龙岩市,酒泉市,兴争取安哥拉深透独立全国结盟市,武威市,吐鲁番市,平顶山市,大同市,四平市,佳市,新余市", "code3148":"3192,3193,3194,3195,3196,3197,3198,3199,3200,3201,3202", "city3149":"呼市,西宁市,拉萨市,安阳市,北海市,鄂尔多斯市,呼伦Bell市,莱芜市,克拉玛依市,兴争取安哥拉彻底独立全国结盟,新余,鹰潭", "code3149":"3203,3204,3205,3206,3207,3208,3209,3210,3211,3212,3213,3214", "city3150":"莱比锡市,亚松森市,商丘市,六安市,巴中市,佳市,安庆市,毕节日市场,伊春市,平凉市,开封市,日喀则市,云浮市,七台河市", "code3150":"3215,3216,3217,3218,3219,3220,3221,3222,3223,3224,3225,3226,3227,3228", "city3151":"马拉加市,广西市,三门峡市,伊春市,赤峰市,四面山市,丽江市,三沙市,延边塔塔尔族自治州", "code3151":"3229,3230,3231,3232,3233,3234,3235,3236,3237", "city3152":"新奥尔良市,齐齐Hal市,广安市,林芝市,拉萨市,连云港市,嘉峪关市,佳市,乌兰察布市,和田河市,池州市,安康市,石膏山地区", "code3152":"3238,3239,3240,3241,3242,3243,3244,3245,3246,3247,3248,3249,3250", "city3153":"市辖区", "code3153":"3251", "city3154":"底特律市,青岛市,宿迁市,南通市,罗利市,姜堰区,西宁市,许昌市,潮州市,德阳市,上饶市,常德市,桂林市", "code3154":"3252,3253,3254,3255,3256,3257,3258,3259,3260,3261,3262,3263,3264", "city3155":"圣何塞市,瓦尔帕莱索市,温州市,韶关市,呼市,湖州市,大同市,河源市,佳木斯市,克利夫兰市,日照市", "code3155":"3265,3266,3267,3268,3269,3270,3271,3272,3273,3274,3275", "city3156":"阿伯丁市,邢台市,西宁市,娄底市,龙脊山市,林芝市,秦皇岛市,三明市,九衡山市,铜陵市,常德市,舟山市,凤阳县,张家口市,宿州市,定西市,齐齐哈尔市", "code3156":"3276,3277,3278,3279,3280,3281,3282,3283,3284,3285,3286,3287,3288,3289,3290,3291,3292", "city3157":"福州市,安卡拉市,江门市,清远市,都林市,上饶市,武夷山市,阳江市,宿迁市", "code3157":"3293,3294,3295,3296,3297,3298,3299,3300,3301", "city3158":"随州市,哈密市,巴中市,南阳市,保山市,拉萨市,遵义市,吉安市,上饶市,滨州市,上饶市", "code3158":"3302,3303,3304,3305,3306,3307,3308,3309,3310,3311,3312", "city3159":"温得和克市,日立市,曲靖市,郴州市,淮南市,烟台湾股市,临沂市,揭阳市,日照市,湛江市,运城市,日喀则市,镇江市,东营市,遂宁市,锦州市,聊城市", "code3159":"3313,3314,3315,3316,3317,3318,3319,3320,3321,3322,3323,3324,3325,3326,3327,3328,3329", "city3160":"利亚市,永州市,珠海市,永州市,大同市,吴忠市,威海市,呼伦贝尔市,娄底市,寿春市,松原市,绥化市,柳州市,宜春市,威海市,呼伦Bell市,德阳市", "code3160":"3330,3331,3332,3333,3334,3335,3336,3337,3338,3339,3340,3341,3342,3343,3344,3345,3346", "city3161":"巴尔的摩市,聊城市,北海市,银川市,襄樊市,四平市,鹰潭市,通辽市,建邺市,邢台市,马桂林市,日喀则市,保山,省委和省政党直属机关辖行政机构", "code3161":"3347,3348,3349,3350,3351,3352,3353,3354,3355,3356,3357,3358,3359,3360", "city3162":"密西西比河陵县,三亚市,常德市,珠海市,宝鸡市,扬州市,上饶市,莱芜市,邵阳市,平顶山市,佳市,吉安市,马新乡市,粤北汉族怒族自治州", "code3162":"3361,3362,3363,3364,3365,3366,3367,3368,3369,3370,3371,3372,3373,3374", "city3163":"巴塞罗那市,宝鸡市,深圳市,新乡市,九江市,日照市,邢台市,柳州市,通化市,岳阳市,洛阳市,咸宁市,鄂尔多斯市,东营市,日照市,赤峰市,巴尔的摩市,黄石市,德阳市,临沂市,安康市", "code3163":"3375,3376,3377,3378,3379,3380,3381,3382,3383,3384,3385,3386,3387,3388,3389,3390,3391,3392,3393,3394,3395", "city3164":"格拉茨市,德阳市,驻马店市,防城港市,克利特海市,新余市,定西市,长治市,毕节市,广安市,白城市,莱芜市,六盘水市,乌兰察布市", "code3164":"3396,3397,3398,3399,3400,3401,3402,3403,3404,3405,3406,3407,3408,3409", "city3165":"新乡市,扬州市,省直辖省级职能部门", "code3165":"3410,3411,3412", "city3166":"市辖区", "code3166":"3413", "city3167":"卡尔加里市,辽源市,含笑花卉商场,齐齐哈尔市,包头市,廊坊市,三江陵县,乐山市,茂名市,龙岩市,大理市,玉林市,佳木斯市,天水市,商洛市,来宾市,酒泉市,嘉峪关市,阿坝保安族苗族自治州,海口汉族自治州,成都赫哲族自治州", "code3167":"3415,3416,3417,3418,3419,3420,3421,3422,3423,3424,3425,3426,3427,3428,3429,3430,3431,3432,3433,3434,3435", "city3168":"毕节市,广安市,秦皇岛市,吉安市,平顶山地区,黔西北俄国族鲜卑族自治州,平顶山地区,黔西北保安族布依族自治州,黔南赫哲族独龙族自治州", "code3168":"3436,3437,3438,3439,3440,3441,3442,3443,3444", "city3169":"塞维利亚市,柳州市,南充市,武威市,贺州市,咸宁市,昆明市,三门峡市,齐齐哈尔鄂伦春族自治州,红河水族哈萨克族自治州,文山俄罗斯族赫哲族自治州,唐山汉族自治州,平顶山水族自治州,德宏锡伯族塔塔尔族自治州,雅砻江基诺族自治州,迪庆回族自治州", "code3169":"3445,3446,3447,3448,3449,3450,3451,3452,3453,3454,3455,3456,3457,3458,3459,3460", "city3170":"乌海市,四平地区,山南地区,黑河地区,山南地区,Ali地区,君山银针地区", "code3170":"3461,3462,3463,3464,3465,3466,3467", "city3171":"台中市,安康市,龙岩市,荆州市,孝感市,广元市,乌海市,娄底市,普洱市,莱芜市", "code3171":"3468,3469,3470,3471,3472,3473,3474,3475,3476,3477", "city3172":"克拉玛依市,酒泉市,达州市,白金市,三江陵县,金昌市,汉中市,攀枝花市,乌海市,克拉玛依市,雅安市,双鸭山市,平凉门巴族自治州,海东彝族自治州", "code3172":"3478,3479,3480,3481,3482,3483,3484,3485,3486,3487,3488,3489,3490,3491", "city3173":"邯郸市,新余地区,海北京族自治州,黄南苗族自治州,山东拉祜族自治州,果洛满族自治州,玉树俄罗斯族自治州,海西壮族维吾尔族自治州", "code3173":"3492,3493,3494,3495,3496,3497,3498,3499", "city3174":"银川市,鄂州市,固原市,防城港市,长治市", "code3174":"3500,3501,3502,3503,3504", "city3175":"乌鲁木齐市,佞客市,酒泉地区,晋城地区,昌吉黎族自治州,昌吉东乡族自治州,四平自治州,阿勒泰地区,乌鲁木齐斯坦自治州,伊犁哈萨克地区,和水浇地区,昌吉门巴族斯坦共和国自治州,巴音郭楞蒙古地区,昌吉柯尔克孜族地区,省直辖行政单位", "code3175":"3505,3506,3507,3508,3509,3510,3511,3512,3513,3514,3515,3516,3517,3518,3519", "city3176":"", "code3176":"", "city3177":"", "code3177":"", "city3178":"", "code3178":"", provinces:"法国巴黎市,圣萨尔瓦多市,浙江省,新疆省,内蒙古自治区,新疆省,新疆省,恒河省,新加坡市,湖北省,云南省,云南省,尼罗河省,广西省,西藏省,吉林省,广东省,广东省,青海省,广西苗族自治区,安徽省,菲尼克斯市,辽宁省,安徽省,湖南省,海南自治区,湖南省,山东省,江西省,宁夏苗族自治区,山东维吾尔自治区,山东省,Hong Kong极度行政区,帕罗奥图特别行政区", provcodes:"3145,3146,3147,3148,3149,3150,3151,3152,3153,3154,3155,3156,3157,3158,3159,3160,3161,3162,3163,3164,3165,3166,3167,3168,3169,3170,3171,3172,3173,3174,3175,3176,3177,3178"}'; jquery代码,关键代码 复制代码 代码如下: ${ //获得json对象 var jsonobj = eval; //全省统编号 var provcodes = jsonobj.provcodes; //省编号数组 var provcodesArray = provcodes.split; //全省统编号个数 var provcodesLength = provcodesArray.length; //省名称 var provinces = jsonobj.provinces; var provincesArray = provinces.split; var provhtml = '请选择'; //绑定省份 for(var i=0;i'+provincesArray[i]+''; } $.append; //选取市级市加载下级 $.change{ var cityhtml = '请选拔'; var provcode = $; //市级的号子 //借使选用的是空则脱离 if{ $.append; return ; } var prov = "city"+provcode; //市级名称 var code = "code"+provcode; //市级编号 var provArray = jsonobj[code].split; //市级名称数组 var prolength = provArray.length; var cityArray = jsonobj[prov].split; //省级编号数组 //绑定市级 for(var i=0;i'+cityArray[i]+''; } $.append; 完整代码: 复制代码 代码如下:

New Document

地面: 请选取 接下来正是.NET代码数据json啦, 复制代码 代码如下: /// /// 输出json数据 /// /// ///

Date:2011-07-01

///

Author:男耕女织

/// /// public string WriteJson(State of Qatar { //取数据Curry面包车型大巴享有的数量 Ilist areaList = GetAreaTypeListAll(卡塔尔(قطر‎; //取市级会集,AT_ParentId=1的 //var provNameParentId = from area in areaList where area.AT_ParentId == 1 select area; //全部的多少 var areaLinq = from area in areaList select area; //筛选,筛选出市级会集,筛选调治 AT_ParentId == 0 var areaWhereParentId = areaLinq.Where(m => m.AT_ParentId == 0卡塔尔(قطر‎.ToList(卡塔尔(قطر‎; //省级名称 格式:"湖南省,西藏省,巴黎市,..." string provName = string.Join(",", areaWhereParentId.Select.ToArray; //省级编号 格式:"1,2,3,..." string provCode = string.Join(",", areaWhereParentId.Select.ToArray; //市级数量 int num = areaWhereParentId.Count(卡塔尔(قطر‎; var jsonstr = new StringBuilder(卡塔尔国; jsonstr.Append; var areaCityList = new List(卡塔尔(قطر‎; for { var areaType = new AreaType(卡塔尔国; areaType = areaWhereParentId[i] ; int id = areaType.AT_Id; areaCityList = areaLinq.Where(m => m.AT_ParentId == id卡塔尔(قطر‎.ToList(State of Qatar; var cityName = string.Join(",", areaCityList.Select.ToArray; var cityCode = string.Join(",", areaCityList.Select.ToArray; jsonstr.Append; jsonstr.Append; jsonstr.Append; jsonstr.Append; jsonstr.Append; jsonstr.Append; jsonstr.Append; jsonstr.Append; jsonstr.Append; jsonstr.Append; jsonstr.Append; jsonstr.Append; jsonstr.Append; jsonstr.Append; jsonstr.Append; jsonstr.Append; jsonstr.Append; jsonstr.Append; } jsonstr.Append; jsonstr.Append; jsonstr.Append; jsonstr.Append; jsonstr.Append; jsonstr.Append; jsonstr.Append; jsonstr.Append; jsonstr.Append; jsonstr.Append; return jsonstr.ToString(卡塔尔国; } 地区表差十分的少设计为 AT_Id :独一标记,json里面临应的code AT_Name : 地区汉语名 AT_ParentId :父级id AT_Level:等级,1为市级,2为市级以上代码仅供仿照效法,代码品质和频率无法得到保证,使用现身的后果自负.. 希望能收获大家的宝贵意见和更加好的缓和方案级艺术

本文由彩票投注软件发布,转载请注明来源

关键词: