Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

add item in listbox in vbscript

654 views
Skip to first unread message

snake

unread,
Dec 16, 1999, 3:00:00 AM12/16/99
to
hello
Would you mind tell me how to add item in listbox ( HTML
<SELECT></SELECT> ) in vbscript.I had used the <listboxname>.add(item,)
function to add some item in the listbox,but the <item> can not be a
string ,and I don't know how to create a item object in vbscript .
Thanks in advance.
yours
snake

--
Posted via CNET Help.com
http://www.help.com/

Adrian Forbes

unread,
Dec 16, 1999, 3:00:00 AM12/16/99
to
objOption = document.createElement('OPTION');
objOption.text = 'My Text;
objOption.value = 'MyValue';
frmForm.cboCombo.add (objOption);


snake

unread,
Dec 17, 1999, 3:00:00 AM12/17/99
to
dear Adrian Forbes:
Thanks for your help.with your help,I write the following codes:
<form name="frmform" >
<select name="cbocombo">
<option>
<option>hello
</select>
</form>
<script language=vbscript>
dim objoption

set objOption = document.createElement ("OPTION")


objOption.text = "My Text"
objOption.value = "MyValue"

frmForm.cboCombo.add (objOption)
window.alert document.url
</script>
it works very well.I am very glap to have your help , thanks again!
best regards

Mark Holman

unread,
Dec 22, 1999, 3:00:00 AM12/22/99
to
Snake,

You first need to create the <option> object.

Set objOpt = document.createElement("OPTION")

Specify the value and text to the Option Object

objOpt.value ="Value1"
objOpt.text = "Text"
objOpt.Id = "ID"

Then to add that particular Option Object, add to the Select Object

SomeSelectObject.options.add(objOpt)

Hope this helps,
Mark Holman


snake <px...@yahoo.com> wrote in message
news:s5gg4rk...@corp.supernews.com...


> hello
> Would you mind tell me how to add item in listbox ( HTML
> <SELECT></SELECT> ) in vbscript.I had used the <listboxname>.add(item,)
> function to add some item in the listbox,but the <item> can not be a
> string ,and I don't know how to create a item object in vbscript .
> Thanks in advance.

0 new messages