<SELECT NAME="select1"><option>1</option><option>1</option><option>1</option></SELECT>
<SCRIPT LANGUAGE="JavaScript">
<!--
while (select1.options.length>0) select1.options.remove(0);
//alert(select1.options.length);
//-->
</SCRIPT>
<SCRIPT LANGUAGE="JavaScript">
<!--
while (select1.options.length>0) select1.options.remove(0);
//alert(select1.options.length);
//-->
</SCRIPT>
<head>
<script language="javascript">
function funcDel(obj){
var sa = document.frm.elements[obj];
for(i = 0; i<sa.options.length; i++){
sa.options[i]=null;
}
}
</script>
</head>
<form name=frm>
<body>
<select name=sel style="width:50">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
</select>
<input type=button name=but value="delete" onclick="funcDel('sel')">
</form>
</body>
</html>
这样可以吗
对于select,最好不要乱用innerHTML修改option,否则会出现你想不到的问题!
建议是用remove方法删除指定的option,删除所有指定selectName.options.length=0;