//动态创建下拉菜单
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>无标题文档</title>
<script>
function selected(){
var con=[["选择城市"],["海淀","朝阳","丰台"],["佳木斯","哈尔滨"],["长春","四平","榆树"]];
var se=document.getElementById("seid");
var index=se.selectedIndex;//得到当前选择下拉菜单内容的索引。
// alert(index);
var citys=con[index];
var tg=document.getElementById("tag");
//alert(tg.name);
tg.options.length=0;//清空选择下拉菜单
for(var x=0;x<citys.length;x++){
var op=document.createElement("option");//创建节点
op.innerText=citys[x];//生成下拉菜单内容
tg.appendChild(op);//添加到select节点中
}
}
</script>
</head>
<body>
<select id="seid" οnchange="selected()">
<option>选择城市</option>
<option>北京市</option>
<option>黑龙江省</option>
<option>吉林省</option>
</select>
<select name="tagname" id="tag">
<option>选择城市</option>
</select>
</body>
</html>