<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head><body bgcolor="#FFFFFF" text="#000000">
<form name="form1" method="post" action="">
<SELECT ID="oSelect">
<OPTION VALUE="1">One</OPTION>
</SELECT><SCRIPT>
var oOption = document.createElement("OPTION");
document.form1.oSelect.options.add(oOption);
oOption.innerText = "Two";
oOption.value = "2";
</SCRIPT>
</form>
</body>
</html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head><body bgcolor="#FFFFFF" text="#000000">
<form name="form1" method="post" action="">
<SELECT ID="oSelect">
<OPTION VALUE="1">One</OPTION>
</SELECT><SCRIPT>
var oOption = document.createElement("OPTION");
document.form1.oSelect.options.add(oOption);
oOption.innerText = "Two";
oOption.value = "2";
</SCRIPT>
</form>
</body>
</html>
解决方案 »
- ext4中,要实现类似表格那种列表用那个组件比较好?
- 用IE查看JSP文件,刷新后直接显示代码是怎么回事
- 求正则:各位大神帮帮忙
- 在JSP中,如何获取鼠标点击控件的值
- JS取值问题
- 点击input输入框弹出选择层(基于jquery),我有问题请教!
- webkit内核的浏览器 被ajax加载后 里面的script标签中的脚本 不被执行 请问大家是怎么解决的??
- 导出excel问题,怎样在javascript程序里自动退出excel?
- 请教各位DX:关于iframe中显示图片的问题
- 有什么方法可以去掉字符串左右两边的空格?????
- 如何在父窗口捕获子窗口的事件?
- 怎样打开客户端的一个文本文件(.txt),把其中的内容提交到当前 form 的 <textarea></textarea> 中,谢谢!
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head><body bgcolor="#FFFFFF" text="#000000">
<form name="form1" method="post" action="">
<SELECT ID="oSelect">
<OPTION VALUE="1">One</OPTION>
</SELECT><SCRIPT>
var oOption = document.createElement("OPTION");
form1.oSelect.options.add(oOption);
oOption.innerText = "Two";
oOption.value = "2";
oSelect.options.remove(0);
oSelect.options.remove(1);//oSelect.options.remove(0);
</SCRIPT>
</form>
</body>
</html>不行,第二项并没有被清除,改成这样两句就可以了:
oSelect.options.remove(0);
oSelect.options.remove(0);为什么?
oSelect.options.remove(1);
oSelect.options.remove(0);
oSelect.options.remove(1);//oSelect.options.remove(0);删除了一个,下面的一个就自动上移了啊~~~一般都需要指出引用的对象的全名:)
oSelect.options.remove(0);
oSelect.options.remove(0);
有错误,应该是:
document.form1.oSelect.options.remove(0);
document.form1.oSelect.options.remove(0);