为select 动态添加option
<html>
<head></head>
<body onload="addOptions()">
<select id="selectItem">
</select>
</body>
<html>
<script type="text/javascript">
function addOptions() {
var selectItem = document.getElementById("selectItem");
var ss = "['选项1','选项2','选项3']";
var aa = eval(ss);
for(var i=0;i<aa.length;i++) {
selectItem.add(new Option(aa[i],aa[i]));
}
}
</script>
<script type="text/javascript">
var type = document.getElementsByName("type");
while(type.options.length>1) {
type.remove(type.options.length-1);
}
var json = eval("("+returnValue+")");
var id = json.id;
var name = json.name;
for(var i=0;i<name.length;i++) {
type.add(new Option(name[i],id[i]))
}
</script>