-
I have a html page with a list box.
<HTML>
<BODY>
<form name=blah>
<SELECT size=2 id=select1 name=select1 style="WIDTH: 80px; HEIGHT: 130px">
<OPTION>test1</OPTION>
<OPTION>test2</OPTION>
<OPTION>test3</OPTION>
</SELECT>
<BR>
<BR>
<BR>
<input type="button" value="Move" onclick='doo();'>
</form>
I can't for the life of me add to this list. I thought it would be document.blah.select1.add "test4"
,But I keep getting a type mismatch error. Can anyone help me on this.
-
I would recomend also using the value attribute in the option tags or you wont be able to get any data from this select after you submit to your processing page. (Only the Value is passed, not the innerText of the option tag)
Here is code to add one in javascript:
Code:
var colOptions = blah.select1.options;
var objOption;
objOption = document.createElement("OPTION");
colOptions.add(objOption);
objOption.innerText="Test4";
objOption.value="4";
VBScript:
Code:
Dim colOptions
Dim objOption;
Set colOptions = = blah.select1.options
Set objOption = document.createElement("OPTION")
colOptions.add(objOption)
objOption.innerText="Test4" objOption.value="4"
Set objOption = Nothing
Set colOptions = Nothing
-
Thanks for the help friend