代码如下:
<body>
<form>
<select id="sheng">
<option value="0">湖北省</option>
<option value="1">广东省</option>
<option value="2">湖南省</option>
<option value="3">安徽省</option>
<option value="4">河南省</option>
</select>
<select id="shi">
<option value="">--请选择--</option>
</select>
</form>
<script type="text/javascript">
var sheng=document.getElementById("sheng");
var shi=document.getElementById("shi");
var city=[];
city[0]=["武汉市","襄阳市","黄冈市","孝感市","仙桃市"];
city[1]=["广州市","东莞市","深圳市","珠海市","江门市"];
city[2]=["长沙市","常德市","衡阳市","郴州市","邵阳市"];
city[3]=["合肥市","蚌埠市","淮南市","淮北市","黄山市"];
city[4]=["郑州市","安阳市","邓州市","新乡市","驻马店市"];
sheng.onchange=function(){
for(var i=0;i<city[this.value];i++){
shi.add(new Option(city[this.value][i],city[this.value][i]));
}
}
</script>
</body>
以上代码为什么没有效果?this.value 确实是获得了value的属性,为什么shi.add(new Option(city[this.value][i],city[this.value][i]));这一段没气作用呢?
谢谢大神!