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...
# 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");
# 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...
# 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?
# 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.....