
how to add OPTION element in SELECT at runtime using Client side vbscripting
An interesting observation...
In IE5.5, setting properties on the new option element first and then adding it causes the add to
fail with "Invalid argument"...
...
set mOption = document.createElement("OPTION")
mOption.innerText = "Two"
mOption.Value = "2"
oSelect.options.add mOption
...
The doc's don't say the order is significant and I don't recall this order failing in IE4.x or IE5.x
versions prior to IE5.5...
--
Michael Harris
MVP Scripting
hope this helps,
<html>
<body>
<SELECT ID="oSelect">
<OPTION VALUE="1">One</OPTION>
</SELECT>
<SCRIPT language=vbscript>
sub create()
dim mOption
set mOption = document.createElement("OPTION")
oSelect.options.add mOption
mOption.innerText = "Two"
mOption.Value = "2"
end sub
</SCRIPT>
<input type=button value=create onclick="create()">
</body>
</html>
Dharmaraj.
Quote:
> how to add OPTION element in SELECT at runtime using Client side
vbscripting