问答文章1 问答文章501 问答文章1001 问答文章1501 问答文章2001 问答文章2501 问答文章3001 问答文章3501 问答文章4001 问答文章4501 问答文章5001 问答文章5501 问答文章6001 问答文章6501 问答文章7001 问答文章7501 问答文章8001 问答文章8501 问答文章9001 问答文章9501

ASP.net 用C#实现 DropDownList二级无刷新互联,省份城市,求指导

发布网友 发布时间:2022-04-24 23:17

我来回答

5个回答

热心网友 时间:2022-04-25 00:46

function Dsy()
{
this.Items = {};
}
Dsy.prototype.add = function(id,iArray)
{
this.Items[id] = iArray;
}
Dsy.prototype.Exists = function(id)
{
if(typeof(this.Items[id]) == "undefined") return false;
return true;
}

function change(v){
var str="0";
for(i=0;i<v;i++){ str+=("_"+(document.getElementById(s[i]).selectedIndex-1));};
var ss=document.getElementById(s[v]);
with(ss){
length = 0;
options[0]=new Option(opt0[v],opt0[v]);
if(v && document.getElementById(s[v-1]).selectedIndex>0 || !v)
{
if(dsy.Exists(str)){
ar = dsy.Items[str];
for(i=0;i<ar.length;i++)options[length]=new Option(ar[i],ar[i]);
if(v)options[1].selected = true;
}
}
if(++v<s.length){change(v);}
}
}

var dsy = new Dsy();

dsy.add("0",["安徽","北京","福建","甘肃","广东","广西","贵州","海南","河北","河南","黑龙江","湖北","湖南","吉林","江苏","江西","辽宁","内蒙古","宁夏","青海","山东","山西","陕西","上海","四川","天津","*","新疆","云南","浙江","重庆"]);

dsy.add("0_0",["安庆","蚌埠","巢湖","池州","滁州","阜阳","合肥","淮北","淮南","黄山","六安","马鞍山","宿州","铜陵","芜湖","宣城","亳州"]);
dsy.add("0_1",["北京"]);

dsy.add("0_2",["福州","龙岩","南平","宁德","莆田","泉州","三明","厦门","漳州"]);
dsy.add("0_3",["白银","定西","甘南藏族自治州","嘉峪关","金昌","酒泉","兰州","临夏回族自治州","陇南","平凉","庆阳","天水","武威","张掖"]);
dsy.add("0_4",["潮州","东莞","佛山","广州","河源","惠州","江门","揭阳","茂名","梅州","清远","汕头","汕尾","韶关","深圳","阳江","云浮","湛江","肇庆","中山","珠海"]);
dsy.add("0_5",["百色","北海","崇左","防城港","桂林","贵港","河池","贺州","来宾","柳州","南宁","钦州","梧州","玉林"]);
dsy.add("0_6",["安顺","毕节","贵阳","六盘水","黔东南苗族侗族自治州","黔南布依族苗族自治州","黔西南布依族苗族自治州","铜仁","遵义"]);
dsy.add("0_7",["白沙黎族自治县","保亭黎族苗族自治县","昌江黎族自治县","澄迈县","定安县","东方","海口","乐东黎族自治县","临高县","陵水黎族自治县","琼海","琼中黎族苗族自治县","三亚","屯昌县","万宁","文昌","五指山","儋州"]);
dsy.add("0_8",["保定","沧州","承德","邯郸","衡水","廊坊","秦皇岛","石家庄","唐山","邢台","张家口"]);

dsy.add("0_9",["安阳","鹤壁","济源","焦作","开封","洛阳","南阳","平顶山","三门峡","商丘","新乡","信阳","许昌","郑州","周口","驻马店","漯河","濮阳"]);
dsy.add("0_10",["大庆","大兴安岭","哈尔滨","鹤岗","黑河","鸡西","佳木斯","牡丹江","七台河","齐齐哈尔","双鸭山","绥化","伊春"]);
dsy.add("0_11",["鄂州","恩施土家族苗族自治州","黄冈","黄石","荆门","荆州","潜江","神农架林区","十堰","随州","天门","武汉","仙桃","咸宁","襄樊","孝感","宜昌"]);
dsy.add("0_11_0",["鄂州市"]);
dsy.add("0_12",["常德","长沙","郴州","衡阳","怀化","娄底","邵阳","湘潭","湘西土家族苗族自治州","益阳","永州","岳阳","张家界","株洲"]);
dsy.add("0_13",["白城","白山","长春","吉林","辽源","四平","松原","通化","延边朝鲜族自治州"]);
dsy.add("0_14",["常州","淮安","连云港","南京","南通","苏州","宿迁","泰州","无锡","徐州","盐城","扬州","镇江"]);
dsy.add("0_15",["抚州","赣州","吉安","景德镇","九江","南昌","萍乡","上饶","新余","宜春","鹰潭"]);
dsy.add("0_16",["鞍山","本溪","朝阳","大连","丹东","抚顺","阜新","葫芦岛","锦州","辽阳","盘锦","沈阳","铁岭","营口"]);
dsy.add("0_17",["阿拉善盟","巴彦淖尔盟","包头","赤峰","鄂尔多斯","呼和浩特","呼伦贝尔","通辽","乌海","乌兰察布盟","锡林郭勒盟","兴安盟"]);
dsy.add("0_18",["固原","石嘴山","吴忠","银川"]);
dsy.add("0_19",["果洛藏族自治州","海北藏族自治州","海东","海南藏族自治州","海西蒙古族藏族自治州","黄南藏族自治州","西宁","玉树藏族自治州"]);
dsy.add("0_20",["滨州","德州","东营","菏泽","济南","济宁","莱芜","聊城","临沂","青岛","日照","泰安","威海","潍坊","烟台","枣庄","淄博"]);

dsy.add("0_21",["长治","大同","晋城","晋中","临汾","吕梁","朔州","太原","忻州","阳泉","运城"]);

dsy.add("0_22",["安康","宝鸡","汉中","商洛","铜川","渭南","西安","咸阳","延安","榆林"]);

dsy.add("0_23",["上海"]);
dsy.add("0_24",["阿坝藏族羌族自治州","巴中","成都","达州","德阳","甘孜藏族自治州","广安","广元","乐山","凉山彝族自治州","眉山","绵阳","南充","内江","攀枝花","遂宁","雅安","宜宾","资阳","自贡","泸州"]);
dsy.add("0_25",["天津"]);

dsy.add("0_26",["阿里","昌都","拉萨","林芝","那曲","日喀则","山南"]);
dsy.add("0_27",["阿克苏","阿拉尔","巴音郭楞蒙古自治州","博尔塔拉蒙古自治州","昌吉回族自治州","哈密","和田","喀什","克拉玛依","克孜勒苏柯尔克孜自治州","石河子","图木舒克","吐鲁番","乌鲁木齐","五家渠","伊犁哈萨克自治州"]);
dsy.add("0_28",["保山","楚雄彝族自治州","大理白族自治州","德宏傣族景颇族自治州","迪庆藏族自治州","红河哈尼族彝族自治州","昆明","丽江","临沧","怒江傈傈族自治州","曲靖","思茅","文山壮族苗族自治州","西双版纳傣族自治州","玉溪","昭通"]);
dsy.add("0_29",["杭州","湖州","嘉兴","金华","丽水","宁波","绍兴","台州","温州","舟山","衢州"]);

dsy.add("0_30",["重庆"]);

热心网友 时间:2022-04-25 02:04

1.使用C#自带AJAX控件 UpdatePanel (推荐)
2.使用JS Ajax(不推荐 没有JQuery方便)
3.使用JQuery Ajax(推荐)
4.使用Js 将所有数据写死在里面(最不推荐 最笨 最麻烦的方法 不需要数据库支持)
前三种需要数据源支持...推荐Xml 因为省份和城市 并不会经常去修改 一般只需读取...所有 XML 就行了 处理速度相对较快

热心网友 时间:2022-04-25 03:39

需要关联数据库 中国有三十几省份,三百多个中大型城市,不关联不行的

热心网友 时间:2022-04-25 05:30

用js或者jquery实现

热心网友 时间:2022-04-25 07:38

ajax实现联动
声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com
“笑指旧山归路长”的出处是哪里 PCB为什么要拼板,PCB拼板打样有哪些好处? 绘制紫外吸收光谱时,我发现最大吸收波长是333nm,此时吸光度为4.01 对吸光度测量值有何影响? 陆垚知马俐的歌词是什么? 玫瑰花水中的养殖方法 陈年柚子茶如何做 陈年柚子茶的制作方法 在答题卡上改题号是指那一道题扣分还是整个卷子都没? ...考试时我写到了卷子上,会怎么样?会不会按抄袭 高考时在卷子上不小心画了道怎么办? 谁知道红酒的价格? 论诉在行政法领域如何体现尊重和保障人权的宪法原则 慕醇古堡的介绍 结合工作实际你将如何践行尊重原则 如何理解“相互尊重”的人际交往的原则?“相互尊重”具体体现在哪些方面? 在涉外商务交往中如何理解尊重原则,重点是尊重原则啊,尊重原则! 以下哪种行为不能体现人际交往中的尊重原则 A.减少对他人的指责 B.温和地表达? 广义的尊重原则又称() 在涉外商务交往中如何理解和体现尊重原则 商务礼仪中如何体现尊重原则 生命伦理四原则的尊重原则 广义的尊重原则又称 你认为怎样才能在沟通交流中体现尊重原则? 体现尊重原则的是 哪种燃气灶火大 我想设计几个漂亮的桌面该怎么弄?桌面上的图标也想换其他的 hp2170p 设置第一启动项? 我想提问一下惠普笔记本如何进入系统启动项菜单?我由于安装了win7和ubun HP 开机出现启动菜单 可以连接老家的wifi吗 Reno2 Z如何设置WLAN直连? win7,XP和上帝模式 win7的“上帝模式”XP能用吗? 有什麽方法能让任何密码进入系统 上帝模式怎么隐藏扩展名? 白菜馅儿的饺子怎么做好吃 jquery 清空dropdownlist 微淼小白营提供的华泰证券账户福利是骗人的吗? 我在微信办理的公积金销户提取成功,但是账户现在还是封存状态,而不是办理销户状态,社保没结算_百度问一问 2022出生人口是多少? 谯城区2022年出生人口 用jquery如何写dropdownlist的onchange事件 彩钢板屋顶的的坡度问题 彩钢瓦屋顶,跨度10米,高差0.3米,这样的坡度是多少?合适吗? 请问彩钢屋面板怎样计算,有坡度系数 端坐、笔端、云端、树端的端哪个意思不同? 标题 有什么办法评估彩钢瓦屋面承重是要得还是要不得? 彩钢瓦房计算平方怎么计算?如果自己居住的那种房子,怎么算平方啊? 笔端的端什么意思? 述诸笔端什么意思