how to add OPTION element in SELECT at runtime using Client side vbscripting 
Author Message
 how to add OPTION element in SELECT at runtime using Client side vbscripting

how to add OPTION element in SELECT at runtime using Client side VBScripting


Sat, 18 Jan 2003 03:00:00 GMT  
 how to add OPTION element in SELECT at runtime using Client side vbscripting

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



Sat, 18 Jan 2003 03:00:00 GMT  
 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



Sat, 18 Jan 2003 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. HOW to add VALUES to COMBOBOX (HTML SELECT)at run time on CLIENT SIDE using VBSCRIPT

2. Adding options to a select element

3. Adding OPTION Element to SELECT

4. Dynamic adding options to <select> element

5. CDO using select element options Help!!!!!!!!!

6. How to dynamically select option in select element?

7. Excel sheet & client side VBScripting

8. client-side VBscripting question

9. changing select options based on previously selected options

10. How to Show Selected Elements in Multiple Options

11. ?Selecting/Indexing Options elements by Name value

12. Select element doesn't show first option?

 

 
Powered by phpBB® Forum Software