<select id="country" onchange="change(this.value)">
<option value="0">请选择</option>
<option value="中国">中国</option>
<option value="美国">美国</option>
<option value="德国">德国</option>
<option value="日本">日本</option>
</select>
<select id="city">
</select>
//创建一个数组存储数据
var arr=new Array(4);
arr[0]=["中国","南京","抚州","临洮","日喀则","哈密"];
arr[1]=["美国","华盛顿","底特律"];
arr[2]=["德国","慕尼黑","柏林","法兰克福"];
arr[3]=["日本","北海道","大阪"];
function change (val) {
var sel2=document.getElementById("city");
sel2.innerHTML="";
var ops=document.createElement("option");
for (var i = 0; i < arr.length; i++) {
if(arr[i][0]==val)
for (var j = 1; j < arr[i].length; j++) {
var ops=document.createElement("option");
var text1=document.createTextNode(arr[i][j]);
ops.appendChild(text1);
sel2.appendChild(ops);
}
}
}