<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>
解决方案 »
- extjs 左边tree菜单,右边tabpanel中显示grid等信息的问题。
- uploadify插件实现在弹出对话框中,在IE中测试一直报“对象不支持此属性和方法”,但是在火狐和遨游却可以完成实现,未报错。
- window.showModalDialog用法
- IE下在file input上点击回车键,为何无法弹出对话框?
- 真奇怪,opener象我这样用怎么就不行呢?
- 上传文件清空问题!!
- 请教一个年龄算法问题
- 图片+文本交替问题?急~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- 如何把某天所在的周的周一的日期得到?
- 如何用javascript得到任意一个月的最后一天?
- 如何在父窗口捕获子窗口的事件?
- 怎样打开客户端的一个文本文件(.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);