㈠ 用js给select插入option
1、使用innerHTML
<script>
varshosetype=document.createElement("select");//创建select标签
shosetype.setAttribute("id","sc");//设置select的id为“sc"
document.body.appendChild(shosetype);//将select添加到body
varoption="<optionvalue="1">添加成功</option>";//新建options
shosetype.innerHTML=option;//将option添加到select
</script>
2、options.add
//根据select查找对象,
varobj=document.getElementById('mySelect');//获取到id为'mySelect'的select元素
//添加一个选项
obj.add(newOption("文本","值"));//添加select的options这个只能在IE中有效
obj.options.add(newOption("text","value"));//添加select的options这个兼容IE与firefox
㈡ JS如何动态给select的option赋值
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> New Document </title>
<meta http-equiv="Content-Type" content="text/html; charset=GBK" />
<script type="text/javascript">
function change (){
var sel = document.getElementById('sel');
sel.options[0].value = 111;
sel.options[0].text = 111;
}
</script>
</head>
<body>
<select id="sel" style="width:100px;">
<option value="1">1</option>
</select>
<a href="javascript:change();">UPDATE</a>
</body>
</html>
看看是不是你想要的效果,可以根据自己的需求修改一下。