<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>新建网页 1</title>
</head><body>
<input type="button" id="btn" onclick="addItem()">
<select id="slt">
</select>
<input type="text" id="txt">
<script language="javascript">
<!--
function addItem()
{
slt.options[slt.options.length] = new Option( txt.value,txt.value);
}
//-->
</script>
</body></html>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>新建网页 1</title>
</head><body>
<input type="button" id="btn" onclick="addItem()">
<select id="slt">
</select>
<input type="text" id="txt">
<script language="javascript">
<!--
function addItem()
{
slt.options[slt.options.length] = new Option( txt.value,txt.value);
}
//-->
</script>
</body></html>
解决方案 »
- js调试时提示错误: 无法获取属性“setAttribute”的值: 对象为 null 或未定义如何解决!!????
- 页面在Web服务器上能打开,客户端打不开
- javascript验证checkbox问题
- javascript数据库查询
- js调用问题
- 判断只能输入12~15的数字
- javascript+xml模糊查找问题
- 高分求网页的树型菜单的源代码
- 如何制作一个能弹出的层?
- JavaScript 运行时错误: 无法获取未定义或 null 引用的属性“tags”
- js中初级问题---onSubmit和onClick
- 在WORD里,可以对一篇文章中的中英文设置不同的字体,那么HTML文档中是否也可以做到这一点?
function addToSel(value){
if (value.length == 0) return;
var oOpt = document.createElement("option");
oOpt.value = value;
oOpt.innerText = value;
sel.appendChild(oOpt);
}
</script> <select id=sel>
</select><input type=text id=txt>
<input type=button value=addtosel onclick="addToSel(txt.value)">