62,046
社区成员
发帖
与我相关
我的任务
分享
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script language="javascript" type="text/javascript">
var cityList = new Array();
cityList["湖北"] = ["武汉","黄石","黄冈","黄陂","十堰","石首","咸宁"];
cityList["湖南"] = ["长沙","岳阳","衡阳","株州","常阳","张家界"];
cityList["山东"] = ["济南","青岛","烟台"];
function showCity()
{
var frm = document.form1;
var shen = frm.sel_shenList.value;
//清空CityList中的内容
frm.sel_cityList.length = 0;
if(shen == 0)//没有选择
{
return;
}
//alert(cityList[shen].length);
for(var i=0;i<cityList[shen].length;i++)
{
var op = new Option(cityList[shen][i],cityList[shen][i]);//第一个参数是显示的内容,第二个参数是实际存储的值
frm.sel_cityList.options.add(op);
}
}
</script>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<label>
<select name="sel_shenList" id="sel_shenList" onchange="showCity()">
<option value="0">---请选择省份---</option>
<option value="湖北">湖北</option>
<option value="湖南">湖南</option>
<option value="山东">山东</option>
</select>
</label>
<label>
<select name="sel_cityList" id="sel_cityList">
<option value="0">---请选择城市---</option>
</select>
</label>
</form>
</body>
</html>