How to add events to HTML Listbox at runtime

Hi all...
I want to add a particular event to listbox ...
my listbox name is 'ListAudioIn' and i am trying

oOption = document.createElement("OPTION")
oOption.text = "real player"
oOtion.value = 0;
ListAudioIn.add(oOption);

And i am getting an error: ListAudioIn.add is not a function

While other function calls like ListAudioIn.length & ListAudioIn.Remove are properly working.....

plz help!!

Thanks in Advance...
[502 byte] By [Me_Himanshu] at [2007-11-20 11:17:44]
# 1 Re: How to add events to HTML Listbox at runtime
That is because add() does not exist. If you want to create an option at runtime you need to use new Option().

ListAudioIn.options[INDEX] = new Option("Text", "Value");
PeejAvery at 2007-11-8 0:43:23 >
# 2 Re: How to add events to HTML Listbox at runtime
I tried....

ListAudioIn.options[INDEX] = new Option("Text", "Value");

Now I am getting an error..

The function ListAudioIn.options has no properties...
Me_Himanshu at 2007-11-8 0:44:20 >
# 3 Re: How to add events to HTML Listbox at runtime
One thing more....

I am trying to implement this HTML file on Mozilla firefox....
Me_Himanshu at 2007-11-8 0:45:24 >
# 4 Re: How to add events to HTML Listbox at runtime
Did you actually leave "INDEX" in there, or did you put an integer of the index you want to create?
PeejAvery at 2007-11-8 0:46:18 >
# 5 Re: How to add events to HTML Listbox at runtime
Hi...
I gave an integer value to 'INDEX' but still the error remains the same...

ListAudioIn.options has no properties.....
Me_Himanshu at 2007-11-8 0:47:26 >
# 6 Re: How to add events to HTML Listbox at runtime
Sorry...
i was committing a silly mistake...
your command works...
Thanx a lot...
Me_Himanshu at 2007-11-8 0:48:25 >
# 7 Re: How to add events to HTML Listbox at runtime
It happens to all of us. Good luck with the rest! :thumb:
PeejAvery at 2007-11-8 0:49:29 >