一个onchange的应用,可怎么也联动不起来,求指教。
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script language="JavaScript" type="text/javascript">
function ChangeCity(){
var citys= [["沈阳","大连"],["青岛","威海"],["西安","汉中"]];
selected = document.getElementById("province").value;
cityChange=document.getElementById("city");
for(i=0,i<citys[selected-1].length,i++){
cityChange.options[i].value=i+1;
cityChange.options[i].text=citys[selected-1].[i];
}
}
</script>
</head>
<body>
请选择你所在的城市:
<select name="province" id="province" onchange="ChangeCity()">
<option value="1" selected>辽宁</option>
<option value="2">山东</option>
<option value="3">陕西</option>
</select>
<select name="city" id="city" >
<option value="1" selected>沈阳</option>
<option value="2">大连</option>
</select>
</body>
</html>