<script type="text/javascript">
function selcity(){
var arr = [["--选择城市--"],["海定区","东城区","西城区","朝阳区"],["济南","青岛","日照","威海"],
["长沙","郴州","岳阳","株洲"],["广州","深圳","惠州","东莞"]];
var index = document.getElementById("selID").selectedIndex;
var subNode = document.getElementById("subID");
var citys = arr[index];
subNode.options.length = 0; //清空之前选项
for(var x=0;x<citys.length;x++){
var optNode = document.createElement("option");
optNode.innerText = citys[x];
subNode.appendChild(optNode); //选择添加到子选项中
}
}
</script>
<style type="text/css">
</style>
</head>
<body>
<select id="selID" οnchange="selcity()">
<option>--选择省市--</option>
<option>北京</option>
<option>山东</option>
<option>湖南</option>
<option>广东</option>
</select>
<select id="subID">
<option>--选择城市--</option>
</select>
</body>