I’m trying to write a page in which the options available from a select pulldown form element get populated dynamically. Everything works great in Firefox, but with IE, every time I call selectElement.options.add(optionElement), the script stops with the error “Invalid argument”. Here is a very simplified simplified version of the code:
[code]
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01//EN” “http://www.w3.org/TR/html4/strict.dtd”>
<html>
<head>
<title>ie test</title>
</head>
<body>
<form>
<select id=”s”>
<option value=”a”>first</option>
<option value=”b”>second</option>
</select>
</form>
<script type=”text/javascript”>
var s = document.getElementById(‘s’);
var newOpt = document.createElement(‘option’);
newOpt.value = “c”;
newOpt.innerHTML = “third”;
s.options.add(newOpt);
</script>
</body>
</html>
Any help is greatly appreciated!