Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
10-10-2007, 06:14 AM #1
- Join Date
- Oct 2007
- Thanked 0 Times in 0 Posts
How to add events to HTML Listbox at runtime
I am using firefox...
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;
And i am getting an error: ListAudioIn.add is not a function
While other function calls like ListAudioIn.length & ListAudioIn.Remove are properly working......
THEN I TRIED....
ListAudioIn.options[INDEX] = new Option("Text", "Value");
I gave an integer value to 'INDEX'
Now I am getting an error..
The function ListAudioIn.options has no properties...
10-10-2007, 08:23 AM #2
- Join Date
- Sep 2005
- Sydney, Australia
- Thanked 932 Times in 919 Posts
ListAudioIn.options[ListAudioIn.options.length] = new Option('Real Player','0');
Note that you need 'document' and the form name added on the front of ListAudioIn whereever it occurs for the code to work. So if your form is named 'audioForm' then it would be document.audioForm.ListAudioIn.options