<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>
解决方案 »
- 如何控制realplay 快进 后退
- IE6与FIREFOX不同
- 弹出窗口中不执行javascript方法,求救!
- xtree中有没有根据id找到节点的方法?
- 请问可以在CSS里定义<SPAN></SPAN>里面的内容吗?,比如<SPAN>AA</SPAN>
- document.execCommand('undo')在框架网页中不管用,高人指点!
- 有没有办法使鼠标在网页上拖动时,无法选中文字
- [求助]何处有哀乐下载,100分悬赏[求助]
- innerHTML
- 微软的开发者论坛在哪?多谢
- 如何在父窗口捕获子窗口的事件?
- 怎样打开客户端的一个文本文件(.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);