请问如何实现:在网页中选择了国家,下面自动出现该国家的省名供选择

PHP网页,用户点了上面那个select选择国家后,表单其他栏目自动跳出该国家对应的选项,比如可选择的省,可修改的邮编等。。
谢谢~

<script type="text/javascript">
//定义了城市的二维数组,里面的顺序跟省份的顺序是相同的。通过selectedIndex获得省份的下标值来得到相应的城市数组
var city=[
["北京","天津","上海","重庆","香港","澳门"],
["石家庄","唐山","秦皇岛","邯郸","邢台","保定","张家口","承德","沧州","廊坊","衡水"],
["太原","大同","阳泉","长治","晋城","朔州","晋中","运城","忻州","临汾","吕梁"],
["呼和浩特","包头","乌海","赤峰","通辽","鄂尔多斯","呼伦贝尔","巴彦淖尔","乌兰察布","兴安","锡林郭勒","阿拉善"],
["沈阳","大连","鞍山","抚顺","本溪","丹东","锦州","营口","阜新","辽阳","盘锦","铁岭","朝阳","葫芦岛"],
["长春","吉林","四平","辽源","通化","白山","松原","白城","延边"],
["哈尔滨","齐齐哈尔","鸡西","鹤岗","双鸭山","大庆","伊春","佳木斯","七台河","牡丹江","黑河","绥化","大兴安岭"],
["南京","苏州","扬州","无锡","徐州","常州","南通","连云港","淮安","盐城","镇江","泰州","宿迁"],
["杭州","宁波","温州","嘉兴","湖州","绍兴","金华","衢州","舟山","台州","丽水"],
["合肥","芜湖","蚌埠","淮南","马鞍山","淮北","铜陵","安庆","黄山","滁州","阜阳","宿州","巢湖","六安","亳州","池州","宣城"],
["福州","宁德","南平","厦门","莆田","三明","泉州","漳州"],
["南昌","上饶","萍乡","九江","景德镇","新余","鹰潭","赣州","吉安","宜春","抚州"],
["济南","青岛","淄博","枣庄","东营","烟台","潍坊","威海","济宁","泰安","日照","莱芜","临沂","德州","聊城","滨州","菏泽"],
["郑州","开封","洛阳","平顶山","焦作","鹤壁","新乡","安阳","濮阳","漯河","许昌","三门峡","南阳","商丘","信阳","周口","驻马店"],
["武汉","十堰","襄樊","鄂州","黄石","荆州","宜昌","荆门","孝感","黄冈","咸宁","随州","恩施"],
["长沙","株洲","湘潭","岳阳","邵阳","常德","衡阳","张家界","益阳","郴州","永州","怀化","娄底","湘西"],
["广州","清远","潮州","东莞","珠海","深圳","汕头","韶关","佛山","江门","湛江","茂名","肇庆","惠州","梅州","汕尾","阳江","河源","中山","揭阳","云浮"],
["南宁","柳州","桂林","梧州","北海","防城港","钦州","贵港","玉林","百色","贺州","河池","来宾","崇左"],
["海口","三亚"],
["成都","自贡","攀枝花","泸州","德阳","绵阳","广元","遂宁","内江","乐山","南充","宜宾","广安","达州","眉山","雅安","巴中","资阳","阿坝","甘孜","凉山"],
["贵阳","六盘水","遵义","安顺","铜仁","毕节","黔西南","黔东南","黔南"],
["昆明","曲靖","玉溪","保山","昭通","丽江","普洱","临沧","文山","红河","西双版纳","楚雄","大理","德宏","怒江","迪庆"],
["拉萨","昌都","山南","日喀则","那曲","阿里","林芝"],
["西安","铜川","宝鸡","咸阳","渭南","延安","汉中","榆林","安康","商洛"],
["兰州","白银","定西","敦煌","嘉峪关","金昌","天水","武威","张掖","平凉","酒泉","庆阳","临夏","陇南","甘南"],
["西宁","海东","海北","黄南","海南","果洛","玉树","海西"],
["银川","石嘴山","吴忠","固原","中卫"],
["乌鲁木齐","克拉玛依","吐鲁番","哈密","和田","阿克苏","喀什","克孜勒苏柯尔克孜","巴音郭楞蒙古","昌吉","博尔塔拉蒙古","伊犁哈萨克","阿勒泰"],
["台北","高雄","基隆","台中","台南","新竹","嘉义"]
];

function getCity(){
//获得省份下拉框的对象
var sltProvince=document.forms[0].province;
//获得城市下拉框的对象
var sltCity=document.forms[0].city;

//得到对应省份的城市数组
var provinceCity=city[sltProvince.selectedIndex - 1];

//清空城市下拉框,仅留提示选项
sltCity.length=1;

//将城市数组中的值填充到城市下拉框中
for(var i=0;i<provinceCity.length;i++){
sltCity[i+1]=new Option(provinceCity[i],provinceCity[i]);
}
}

</script>

<form action="#" method="POST" name="myform" target="_self" id="myform">
<select name="province" onChange="getCity()">
<option value="null" disabled="disabled">请选择所在省份</option>
<option value="直辖市">直辖市</option>
<option value="河北">河北</option>
<option value="山西">山西</option>
<option value="内蒙古">内蒙古</option>
<option value="辽宁">辽宁</option>
<option value="吉林">吉林</option>
<option value="黑龙江">黑龙江</option>
<option value="江苏">江苏</option>
<option value="浙江">浙江</option>
<option value="安徽">安徽 </option>
<option value="福建">福建 </option>
<option value="江西">江西</option>
<option value="山东">山东</option>
<option value="河南">河南</option>
<option value="湖北">湖北</option>
<option value="湖南">湖南</option>
<option value="广东">广东</option>
<option value="广西">广西</option>
<option value="海南">海南</option>
<option value="四川">四川</option>
<option value="贵州">贵州</option>
<option value="云南">云南</option>
<option value="西藏">西藏</option>
<option value="陕西">陕西 </option>
<option value="甘肃">甘肃 </option>
<option value="青海">青海</option>
<option value="宁夏">宁夏</option>
<option value="新疆">新疆</option>
<option value="台湾">台湾</option>
</select>
 
<select name="city">
<option selected="selected" value="null">请选择所在城市</option>
</select>
</form> 直接用就可以了。这是 省市 2级联动
温馨提示:内容为网友见解,仅供参考
第1个回答  2010-08-20
这是一个级联菜单 在网上有源码的 你找一下 JS的
第2个回答  2010-08-20
网上搜下二级连动的js有源码! ajax实现的也有!

请问如何实现:在网页中选择了国家,下面自动出现该国家的省名供选择
\/\/定义了城市的二维数组,里面的顺序跟省份的顺序是相同的。通过selectedIndex获得省份的下标值来得到相应的城市数组 var city=[["北京","天津","上海","重庆","香港","澳门"],["石家庄","唐山","秦皇岛","邯郸","邢台","保定","张家口","承德","沧州","廊坊","衡水"],["太原","大...

网页自己跳转到指定页面怎么实现?
1.在桌面上创建一个新的文本文档,双击打开它。2.打开文档后,输入下面的代码,其中自动跳转的代码就是红框中的内容。刷新意味着跳跃,30意味着30秒后跳跃到index1.html。3.输入完成后,单击文件菜单,然后选择另存为。4.在弹出的对话框中,选择桌面作为保存位置,然后将文件名的后缀修改为。html,然...

...再设置“市”,如何在选择省后,接下来只显示该省中的市呢_百度...
楼主不明白楼上说的是什么意思?呵呵!是下拉列表联动啊,第一个下拉列表的状态改变时同时更新第二个下拉列表的绑定值。你要的就是这种效果了

打开网页会自动弹出其它的网站,是不是中了病毒?
常见四种情况:一、该网页被设置了弹窗广告,你打开改页面,页面运行自动打开弹窗。和你电脑无关。电脑没有中毒。解决方法:使用浏览器或安全软件的广告过滤(广告拦截)功能,拦截弹窗。可以阻挡大部分弹窗。如下图:1)选择浏览器右上角工具--广告过滤:2)在打开的页面中设置:二、通过点击:工具---...

为什么下面会出现那两个系统文件?软件卸载了,那东西还在那???急...
由于,你双击磁盘会触发木马的启动,所以查杀时,要右键单击,再选择“打开”或用“资源管理器”来查看,找到后删除此文件。通常此文件会以隐藏文件的形式出现,更有些恶毒的会加上“注册表监控并回写”来为文件隐藏护航,你一旦更改系统为“显示所有文件”,它马上会再次改为“不显示隐藏文件”,如何破除这种注册表回写...

iPhone怎么阻止浏览网页时自动切换至App Store?
1、将 iPhone手机解锁后,在手机桌面的应用程序中找到【设置】打开。2、进入手机系统的【设置】详情选项列表后,找到【Safari浏览器】设置进入。3、进入【Safari浏览器】设置的详情页面后,找到【阻止弹出式窗口】功能。4、点击【阻止弹出式窗口】右侧的开关按钮进行激活此功能,成功开启即可阻止浏览网页的...

我在上网的时候会无缘无故的自动不间断出现一些网址,怎样解决这个问题...
我们可以通过以下方法来禁止:依次选择“控制面板→管理工具→服务”,在出现的“服务”窗口中找到“Messenger”项并双击,接着在弹出的“Messenger属性”对话框中选择“常规”选项卡,将“启动类型”改为“已禁止”并单击“停止”按钮即可。问:浏览网页时经常会弹出一些认证的对话框,比如网络实名、点点通...

上网说“此网站含有隐私是否只发送不含隐私的部分”,这是怎么回事?
如果恶意攻击者把该文件换成木马,并修改其中ftp服务器的地址和文件名,将其改为他们的ftp服务器地址和服务器上木马程序的路径。那么当别人浏览该网页时,会出现“Internet Explorer脚本错误”的错误信息,询问是否继续在该页面上运行脚本错误,当点击“是”便会自动下载并运行木马。以上两种网页木马都会弹出安全提示框,因此...

全国企业信用信息公示系统怎么填报
1、网上搜索“信用公示系统”官方网页,然后点击打开。2、进去首页之后,选择你的居住的地方县级市然后确定。3、点击【企业公示信息填报】然后进入【登陆年报系统】界面。5、登录成功后在新的界面点击【年度报告在线填录】即可进行年报的填录。点击年度报告在线填录进入年报录入,首先是基本信息的填录,根据...

如何在 Linux 中根据国家位置来阻断网络流量
1、使用地图模式。在Google地图中,卫星模式需要下载大量卫星照片,而地图模式相对比较简洁,在正确显示地理位置的同时,耗费的流量也比较少。打开菜单中的“地图模式”,选择“地图”模式。2、禁止浏览器载入图片,浏览网页的时候会下载大量图片,这非常耗费流量,你可以打开浏览器,进入设置菜单,取消“载入...

相似回答