js实现二级地域选择
2012-11-02 16:26:01 来源:WEB开发网核心提示:case "海外" : var cityOptions = new Array( "请选择地区", "", "欧洲", "欧洲", "北美", "北美", "南美&quo
case "海外" : var cityOptions = new Array( "请选择地区", "", "欧洲", "欧洲", "北美", "北美", "南美", "南美", "亚洲", "亚洲", "非洲", "非洲", "大洋洲", "大洋洲"); break; default: var cityOptions = new Array("请选择地区", ""); break; } document.creator["city"].options.length = 0; for(var i = 0; i < cityOptions.length/2; i++) { document.creator["city"].options[i]=new Option(cityOptions[i*2],cityOptions[i*2+1]); if (document.creator["city"].options[i].value==city){ document.creator["city"].selectedIndex = i; } } } function creatprovince(province){ var provinces = new Array( "北京", "上海", "重庆", "安徽", "福建", "甘肃", "广东", "广西", "贵州", "海南", "河北", "黑龙江", "河南", "香港", "湖北", "湖南", "江苏", "江西", "吉林", "辽宁", "澳门", "内蒙古", "宁夏", "青海", "山东", "山西", "陕西", "四川", "台湾", "天津", "新疆", "西藏", "云南", "浙江", "海外" ); document.creator["province"].options[0]=new Option("请选择省份",""); for(var i = 0; i < provinces.length; i++) { document.creator["province"].options[i+1]=new Option(provinces[i],provinces[i]); if (document.creator["province"].options[i+1].value==province){ document.creator["province"].selectedIndex = i+1; } } }
</script>
<form name=creator>
<select onchange="initcity();" name="province" >
<SCRIPT>creatprovince();</SCRIPT>
</select>
<select name="city">
<option value="">选择城市</option>
</select>
</form>
</body>
</html>
</script>
<form name=creator>
<select onchange="initcity();" name="province" >
<SCRIPT>creatprovince();</SCRIPT>
</select>
<select name="city">
<option value="">选择城市</option>
</select>
</form>
</body>
</html>
更多精彩
赞助商链接