博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
两级菜单实现
阅读量:5113 次
发布时间:2019-06-13

本文共 9092 字,大约阅读时间需要 30 分钟。

javascript部分:
StringBuilder sb = new StringBuilder();
   sb.Append("<select  οnchange='setcity()' name='province' style='WIDTH:80px'>");
   sb.Append("<OPTION value='' selected>请选择省份</OPTION>");
   sb.Append("</select>");
   sb.Append("<select   name='city' style='WIDTH:80px'>");
   sb.Append("<OPTION value='' selected>请选择城市</OPTION>");
   sb.Append("</select>");
   sb.Append("<script>");
   sb.AppendFormat("var theprovinceid = '{0}';",Province);
   sb.AppendFormat("var thecityid = '{0}';",City);
   sb.Append("</script>");
   sb.Append("<script language=javascript>setprovince();setcity();</script>");
   return sb.ToString();
None.gif
<
script language
=
"
javascript
"
>
None.gif        function setprovince()
ExpandedBlockStart.gifContractedBlock.gif  
dot.gif
{
InBlock.gif  theform 
= Form1;
InBlock.gif  var labels 
= new Array("北京","上海","天津","重庆","黑龙江","辽宁","吉林","河北","内蒙古","陕西","山西","甘肃","宁夏","新疆","西藏","青海","四川","云南","贵州","湖南","湖北","河南","山东","安徽","江苏","浙江","台湾","香港","澳门","广东","广西","江西","福建","海南","其它","美国","欧洲","日本","韩国","新加坡","加拿大","亚 洲","非 洲","澳 洲","南美洲","东南亚");
InBlock.gif  var values 
= new Array("北京","上海","天津","重庆","黑龙江","辽宁","吉林","河北","内蒙古","陕西","山西","甘肃","宁夏","新疆","西藏","青海","四川","云南","贵州","湖南","湖北","河南","山东","安徽","江苏","浙江","台湾","香港","澳门","广东","广西","江西","福建","海南","其它","美国","欧洲","日本","韩国","新加坡","加拿大","亚 洲","非 洲","澳 洲","南美洲","东南亚");
ExpandedSubBlockStart.gifContractedSubBlock.gif  
for(var i = 0; i < labels.length; i++dot.gif
InBlock.gif        theform.province.add(document.createElement(
"OPTION")); 
InBlock.gif        theform.province.options[i].text 
=labels[i]; 
InBlock.gif        theform.province.options[i].value
=values[i];
InBlock.gif
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif        
if(values[i] == theprovinceid)dot.gif{
InBlock.gif           theform.province.options[i].selected 
= true;
ExpandedSubBlockEnd.gif        }
ExpandedSubBlockEnd.gif    }
 
ExpandedBlockEnd.gif}
None.gif
ExpandedBlockStart.gifContractedBlock.giffunction setcity() 
dot.gif
{
InBlock.gif    theform 
=Form1;
ExpandedSubBlockStart.gifContractedSubBlock.gif    
switch (theform.province.value) dot.gif
InBlock.gif        
case '北京' : 
InBlock.gif        var labels 
= new Array("北京市"); 
InBlock.gif        var values 
= new Array("北京市");  
InBlock.gif        
break
InBlock.gif        
case '天津' : 
InBlock.gif        var labels 
= new Array("天津市"); 
InBlock.gif        var values 
= new Array("天津市"); 
InBlock.gif        
break
InBlock.gif        
case '上海' : 
InBlock.gif        var labels 
= new Array("上海市"); 
InBlock.gif        var values 
= new Array("上海市"); 
InBlock.gif        
break
InBlock.gif
InBlock.gif        
case '重庆' : 
InBlock.gif        var labels 
= new Array("重庆市"); 
InBlock.gif        var values 
= new Array("重庆市"); 
InBlock.gif        
break
InBlock.gif        
case '黑龙江' : 
InBlock.gif        var labels 
= new Array("哈尔滨","齐齐哈尔","鸡西","鹤岗","双鸭山","大庆","伊春","佳木斯","七台河","牡丹江","黑河","绥化","松花江","嫩江","合江","大兴安岭"); 
InBlock.gif        var values 
= new Array("哈尔滨","齐齐哈尔","鸡西","鹤岗","双鸭山","大庆","伊春","佳木斯","七台河","牡丹江","黑河","绥化","松花江","嫩江","合江","大兴安岭"); 
InBlock.gif        
break
InBlock.gif        
case '辽宁' : 
InBlock.gif        var labels 
= new Array("沈阳","大连","鞍山","抚顺","本溪","丹东","锦州","营口","阜新","辽阳","盘锦","铁岭","朝阳","葫芦岛"); 
InBlock.gif        var values 
= new Array("沈阳","大连","鞍山","抚顺","本溪","丹东","锦州","营口","阜新","辽阳","盘锦","铁岭","朝阳","葫芦岛"); 
InBlock.gif        
break
InBlock.gif
InBlock.gif        
case '吉林' : 
InBlock.gif        var labels 
= new Array("长春","吉林","四平","辽源","通化","白山","松原","白城","延边","永吉","德惠"); 
InBlock.gif        var values 
= new Array("长春","吉林","四平","辽源","通化","白山","松原","白城","延边","永吉","德惠"); 
InBlock.gif        
break
InBlock.gif        
case '河北' : 
InBlock.gif        var labels 
= new Array("石家庄","唐山","秦皇岛","邯郸","邢台","保定","张家口","承德","沧州","廊坊","衡水"); 
InBlock.gif        var values 
= new Array("石家庄","唐山","秦皇岛","邯郸","邢台","保定","张家口","承德","沧州","廊坊","衡水");
InBlock.gif        
break
InBlock.gif        
case '内蒙古' : 
InBlock.gif        var labels 
= new Array("呼和浩特","包头","乌海","赤峰","通辽","鄂尔多斯","呼伦贝尔盟","兴安盟","哲里木盟","昭乌达盟","锡林郭勒盟","乌兰察布盟","伊克昭盟","巴彦淖尔盟","阿拉善盟");
InBlock.gif        var values 
= new Array("呼和浩特","包头","乌海","赤峰","通辽","鄂尔多斯","呼伦贝尔盟","兴安盟","哲里木盟","昭乌达盟","锡林郭勒盟","乌兰察布盟","伊克昭盟","巴彦淖尔盟","阿拉善盟");
InBlock.gif        
break
InBlock.gif
InBlock.gif        
case '陕西' : 
InBlock.gif        var labels 
= new Array("西安","铜川","宝鸡","咸阳","渭南","延安","汉中","榆林","安康","商洛");
InBlock.gif        var values 
= new Array("西安","铜川","宝鸡","咸阳","渭南","延安","汉中","榆林","安康","商洛");
InBlock.gif        
break
InBlock.gif        
case '山西' : 
InBlock.gif        var labels 
= new Array("太原","大同","阳泉","长治","晋城","朔州","晋中","运城","忻州","临汾","雁北","忻县","吕梁","晋东南");
InBlock.gif        var values 
= new Array("太原","大同","阳泉","长治","晋城","朔州","晋中","运城","忻州","临汾","雁北","忻县","吕梁","晋东南");
InBlock.gif        
break
InBlock.gif        
case '甘肃' : 
InBlock.gif        var labels 
= new Array("兰州","嘉峪关","金昌","白银","天水","武威","酒泉","张掖","定西","陇南","平凉","庆阳","临夏","甘南");
InBlock.gif        var values 
= new Array("兰州","嘉峪关","金昌","白银","天水","武威","酒泉","张掖","定西","陇南","平凉","庆阳","临夏","甘南");
InBlock.gif        
break
InBlock.gif
InBlock.gif        
case '宁夏' : 
InBlock.gif        var labels 
= new Array("银川","石嘴山","吴忠","固原","银南");
InBlock.gif        var values 
= new Array("银川","石嘴山","吴忠","固原","银南");
InBlock.gif        
break
InBlock.gif        
case '新疆' : 
InBlock.gif        var labels 
= new Array("乌鲁木齐","克拉玛依","石河子","吐鲁番","哈密","昌吉","伊犁","塔城","阿勒泰","博尔塔拉","巴音郭楞","阿克苏","克孜勒苏","喀什","和田");
InBlock.gif        var values 
= new Array("乌鲁木齐","克拉玛依","石河子","吐鲁番","哈密","昌吉","伊犁","塔城","阿勒泰","博尔塔拉","巴音郭楞","阿克苏","克孜勒苏","喀什","和田");
InBlock.gif        
break
InBlock.gif        
case '西藏' : 
InBlock.gif        var labels 
= new Array("拉萨","昌都","山南","日喀则","那曲","阿里","林芝","江孜");
InBlock.gif        var values 
= new Array("拉萨","昌都","山南","日喀则","那曲","阿里","林芝","江孜");
InBlock.gif        
break
InBlock.gif
InBlock.gif        
case '青海' : 
InBlock.gif        var labels 
= new Array("西宁","海东","海北","黄南","海南","果洛","玉树","海西");
InBlock.gif        var values 
= new Array("西宁","海东","海北","黄南","海南","果洛","玉树","海西");
InBlock.gif        
break
InBlock.gif        
case '四川' : 
InBlock.gif        var labels 
= new Array("成都","自贡","攀枝花","泸州","德阳","绵阳","广元","遂宁","内江","乐山","万县","南充","眉山","宜宾","广安","达州","雅安","巴中","资阳","永川","涪陵","内江","温江","绵阳","达县","黔江");
InBlock.gif        var values 
=new Array("成都","自贡","攀枝花","泸州","德阳","绵阳","广元","遂宁","内江","乐山","万县","南充","眉山","宜宾","广安","达州","雅安","巴中","资阳","永川","涪陵","内江","温江","绵阳","达县","黔江");
InBlock.gif        
break
InBlock.gif        
case '云南' : 
InBlock.gif        var labels 
= new Array("昆明","东川","曲靖","玉溪","保山","昭通","楚雄","红河","文山","思茅","西双版纳","大理","德宏","丽江","怒江","迪庆","临沧");
InBlock.gif        var values 
= new Array("昆明","东川","曲靖","玉溪","保山","昭通","楚雄","红河","文山","思茅","西双版纳","大理","德宏","丽江","怒江","迪庆","临沧");
InBlock.gif        
break
InBlock.gif
InBlock.gif        
case '贵州' : 
InBlock.gif        var labels 
= new Array("贵阳","六盘水","遵义","安顺","铜仁","黔西南","毕节","黔东南","黔南");
InBlock.gif        var values 
= new Array("贵阳","六盘水","遵义","安顺","铜仁","黔西南","毕节","黔东南","黔南");
InBlock.gif        
break
InBlock.gif        
case '湖南' : 
InBlock.gif        var labels 
= new Array("长沙","株洲","湘潭","衡阳","邵阳","岳阳","常德","张家界","益阳","郴州","永州","怀化","娄底","零陵","怀北","湘西");
InBlock.gif        var values 
= new Array("长沙","株洲","湘潭","衡阳","邵阳","岳阳","常德","张家界","益阳","郴州","永州","怀化","娄底","零陵","怀北","湘西");
InBlock.gif        
break
InBlock.gif        
case '湖北' : 
InBlock.gif        var labels 
= new Array("武汉","黄石","十堰","沙市","宜昌","襄樊","鄂州","荆门","孝感","荆州","黄冈","咸宁","随州","襄阳","郧阳");
InBlock.gif        var values 
= new Array("武汉","黄石","十堰","沙市","宜昌","襄樊","鄂州","荆门","孝感","荆州","黄冈","咸宁","随州","襄阳","郧阳");
InBlock.gif        
break
InBlock.gif
InBlock.gif        
case '河南' : 
InBlock.gif        var labels 
= new Array("郑州","开封","洛阳","平顶山","安阳","鹤壁","新乡","焦作","濮阳","许昌","漯河","三门峡","南阳","商丘","信阳","周口","驻马店");
InBlock.gif        var values 
= new Array("郑州","开封","洛阳","平顶山","安阳","鹤壁","新乡","焦作","濮阳","许昌","漯河","三门峡","南阳","商丘","信阳","周口","驻马店");
InBlock.gif        
break
InBlock.gif        
case '山东' : 
InBlock.gif        var labels 
= new Array("济南","青岛","淄博","枣庄","东营","烟台","潍坊","济宁","泰安","威海","日照","莱芜","临沂","德州","聊城","滨州","荷泽");
InBlock.gif        var values 
= new Array("济南","青岛","淄博","枣庄","东营","烟台","潍坊","济宁","泰安","威海","日照","莱芜","临沂","德州","聊城","滨州","荷泽");
InBlock.gif        
break
InBlock.gif        
case '安徽' : 
InBlock.gif        var labels 
= new Array("合肥","芜湖","蚌埠","淮南","马鞍山","淮北","铜陵","安庆","黄山","滁州","阜阳","宿州","巢湖","六安","亳州","池州","宣城","徽州");
InBlock.gif        var values 
= new Array("合肥","芜湖","蚌埠","淮南","马鞍山","淮北","铜陵","安庆","黄山","滁州","阜阳","宿州","巢湖","六安","亳州","池州","宣城","徽州");
InBlock.gif        
break
InBlock.gif
InBlock.gif        
case '江苏' : 
InBlock.gif        var labels 
= new Array("南京","无锡","徐州","常州","苏州","南通","连云港","淮安","盐城","扬州","镇江","泰州","宿迁","淮阴");
InBlock.gif        var values 
= new Array("南京","无锡","徐州","常州","苏州","南通","连云港","淮安","盐城","扬州","镇江","泰州","宿迁","淮阴");
InBlock.gif        
break
InBlock.gif        
case '浙江' : 
InBlock.gif        var labels 
= new Array("杭州","宁波","温州","嘉兴","湖州","绍兴","金华","衢州","舟山","台州","丽水");
InBlock.gif        var values 
= new Array("杭州","宁波","温州","嘉兴","湖州","绍兴","金华","衢州","舟山","台州","丽水");
InBlock.gif        
break
InBlock.gif        
case '台湾' : 
InBlock.gif        var labels 
= new Array("台湾");
InBlock.gif        var values 
= new Array("台湾");
InBlock.gif        
break
InBlock.gif
InBlock.gif        
case '香港' : 
InBlock.gif        var labels 
= new Array("香港");
InBlock.gif        var values 
= new Array("香港"); 
InBlock.gif        
break
InBlock.gif        
case '澳门' : 
InBlock.gif        var labels 
= new Array("澳门");
InBlock.gif        var values 
= new Array("澳门");
InBlock.gif        
break
InBlock.gif        
case '广东' : 
InBlock.gif        var labels 
= new Array("广州","韶关","深圳","珠海","汕头","佛山","江门","湛江","茂名","海口","肇庆","惠州","梅州","汕尾","河源","阳江","清远","东莞","中山","梅县","惠阳","潮州","揭阳","云浮");
InBlock.gif        var values 
= new Array("广州","韶关","深圳","珠海","汕头","佛山","江门","湛江","茂名","海口","肇庆","惠州","梅州","汕尾","河源","阳江","清远","东莞","中山","梅县","惠阳","潮州","揭阳","云浮");
InBlock.gif        
break
InBlock.gif
InBlock.gif        
case '广西' : 
InBlock.gif        var labels 
= new Array("南宁","柳州","桂林","梧州","北海","防城港","钦州","贵港","玉林","贺州","百色","河池");
InBlock.gif        var values 
= new Array("南宁","柳州","桂林","梧州","北海","防城港","钦州","贵港","玉林","贺州","百色","河池"); 
InBlock.gif        
break
InBlock.gif        
case '江西' : 
InBlock.gif        var labels 
= new Array("南昌","景德镇","萍乡","九江","新余","鹰潭","抚州","上饶","赣州","宜春","吉安");
InBlock.gif        var values 
= new Array("南昌","景德镇","萍乡","九江","新余","鹰潭","抚州","上饶","赣州","宜春","吉安");
InBlock.gif        
break
InBlock.gif        
case '福建' : 
InBlock.gif        var labels 
= new Array("福州","厦门","莆田","三明","泉州","漳州","南平","龙岩","宁德","晋江","龙溪");
InBlock.gif        var values 
= new Array("福州","厦门","莆田","三明","泉州","漳州","南平","龙岩","宁德","晋江","龙溪");
InBlock.gif        
break
InBlock.gif        
case '海南' : 
InBlock.gif        var labels 
= new Array("海口","三亚");
InBlock.gif        var values 
= new Array("海口","三亚");
InBlock.gif        
break
InBlock.gif        
case '美国' : 
InBlock.gif        var labels 
= new Array("美国"); 
InBlock.gif        var values 
= new Array("美国"); 
InBlock.gif        
break;
InBlock.gif        
case '欧洲' : 
InBlock.gif        var labels 
= new Array("欧洲"); 
InBlock.gif        var values 
= new Array("欧洲"); 
InBlock.gif        
break;
InBlock.gif        
case '日本' : 
InBlock.gif        var labels 
= new Array("日本"); 
InBlock.gif        var values 
= new Array("日本");
InBlock.gif        
break;
InBlock.gif        
case '韩国' : 
InBlock.gif        var labels 
= new Array("韩国"); 
InBlock.gif        var values 
=new Array("韩国");  
InBlock.gif        
break;
InBlock.gif        
case '新加坡' : 
InBlock.gif        var labels 
= new Array("新加坡"); 
InBlock.gif        var values 
= new Array("新加坡");
InBlock.gif        
break;
InBlock.gif        
case '加拿大' : 
InBlock.gif        var labels 
= new Array("加拿大"); 
InBlock.gif        var values 
= new Array("加拿大");  
InBlock.gif        
break;
InBlock.gif        
case '亚 洲' : 
InBlock.gif        var labels 
= new Array("亚 洲"); 
InBlock.gif        var values 
= new Array("亚 洲"); 
InBlock.gif        
break;
InBlock.gif        
case '非 洲' : 
InBlock.gif        var labels 
= new Array("非 洲"); 
InBlock.gif        var values 
= new Array("非 洲");  
InBlock.gif        
break;
InBlock.gif        
case '澳 洲' : 
InBlock.gif        var labels 
= new Array("澳 洲"); 
InBlock.gif        var values 
= new Array("澳 洲"); 
InBlock.gif        
break;
InBlock.gif        
case '南美洲' : 
InBlock.gif        var labels 
= new Array("南美洲"); 
InBlock.gif        var values 
= new Array("南美洲"); 
InBlock.gif        
break;
InBlock.gif        
case '东南亚' : 
InBlock.gif        var labels 
= new Array("东南亚"); 
InBlock.gif        var values 
= new Array("东南亚"); 
InBlock.gif        
break;
InBlock.gif        
case '其它' : 
InBlock.gif        var labels 
= new Array("其他"); 
InBlock.gif        var values 
= new Array("其他"); 
InBlock.gif        
break;    
ExpandedSubBlockEnd.gif    }
InBlock.gif
InBlock.gif
InBlock.gif
InBlock.gif
InBlock.gif
// 清空市列表选择框的内容 
InBlock.gif
    theform.city.options.length = 0
InBlock.gif
// 从数组中添加内容 
InBlock.gif
    
InBlock.gif  
ExpandedSubBlockStart.gifContractedSubBlock.gif    
for(var i = 0; i < labels.length; i++dot.gif
InBlock.gif        theform.city.add(document.createElement(
"OPTION")); 
InBlock.gif        theform.city.options[i].text 
=labels[i]; 
InBlock.gif        theform.city.options[i].value
=values[i];
InBlock.gif
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif        
if(values[i] == thecityid)dot.gif{
InBlock.gif           theform.city.options[i].selected 
= true;
ExpandedSubBlockEnd.gif        }
ExpandedSubBlockEnd.gif    }
 
InBlock.gif
// 选择第一个选项  
ExpandedBlockEnd.gif
}
None.gif        
</
script
>

转载于:https://www.cnblogs.com/13306511495/archive/2005/12/20/301148.html

你可能感兴趣的文章
Flask 系列之 SQLAlchemy
查看>>
aboutMe
查看>>
【Debug】IAR在线调试时报错,Warning: Stack pointer is setup to incorrect alignmentStack,芯片使用STM32F103ZET6...
查看>>
一句话说清分布式锁,进程锁,线程锁
查看>>
python常用函数
查看>>
FastDFS使用
查看>>
服务器解析请求的基本原理
查看>>
[HDU3683 Gomoku]
查看>>
【工具相关】iOS-Reveal的使用
查看>>
数据库3
查看>>
存储分类
查看>>
下一代操作系统与软件
查看>>
【iOS越狱开发】如何将应用打包成.ipa文件
查看>>
[NOIP2013提高组] CODEVS 3287 火车运输(MST+LCA)
查看>>
Yii2 Lesson - 03 Forms in Yii
查看>>
Python IO模型
查看>>
Ugly Windows
查看>>
DataGridView的行的字体颜色变化
查看>>
Java再学习——关于ConcurrentHashMap
查看>>
如何处理Win10电脑黑屏后出现代码0xc0000225的错误?
查看>>