Netscape does not support remove() and add(), you need to add a new option to the options collection and delete a option by setting the option to null; for example:
<script language="javascript">
function showSelection()
{
alert(document.form1.sel1.value);
var n = document.form1.sel1.selectedIndex;
var option = document.form1.sel1.options[n];
alert(option.text + ":" + option.value);
}function addOption()
{
var opt = new Option("Five","5");
var options = document.form1.sel1.options;
var n = options.length;
options[n] = opt;
document.form1.sel1.selectedIndex = n;
}function deleteOption()
{
var options = document.form1.sel1.options;
if (options.length > 2)
options[2] = null;
}
</script>
<form name="form1">
<select name="sel1">
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
<option value="4">Four</option>
</select>
<input type="button" value="show selection" onclick="showSelection()">
<input type="button" value="add option" onclick="addOption()">
<input type="button" value="delete option 2" onclick="deleteOption()">
</form>
<script language="javascript">
function showSelection()
{
alert(document.form1.sel1.value);
var n = document.form1.sel1.selectedIndex;
var option = document.form1.sel1.options[n];
alert(option.text + ":" + option.value);
}function addOption()
{
var opt = new Option("Five","5");
var options = document.form1.sel1.options;
var n = options.length;
options[n] = opt;
document.form1.sel1.selectedIndex = n;
}function deleteOption()
{
var options = document.form1.sel1.options;
if (options.length > 2)
options[2] = null;
}
</script>
<form name="form1">
<select name="sel1">
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
<option value="4">Four</option>
</select>
<input type="button" value="show selection" onclick="showSelection()">
<input type="button" value="add option" onclick="addOption()">
<input type="button" value="delete option 2" onclick="deleteOption()">
</form>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货