Click to See Complete Forum and Search --> : Listbox; adding new values in client side


cpb123
May 16th, 2005, 02:35 PM
Hi,

I am wanting to add new values to a listbox using client side scripting. I want to get values from a textfield and add it to the listbox through client side scripting.

I know that you can remove values from a listbox using the following code:

form.lstBox.remove(0) '0 being the index value
I have searched everywhere to find an answer and I can't find a solution. Please can somebody tell me whether this is possible or not.
Thank you.

Dr. Script
May 16th, 2005, 05:45 PM
If you searched, well, you'd realize this is very easy. var s = document.forms['frmNom']['sbxNom'];
s.options[s.options.length] = new Option('value','text',false); /* true would select it */There is an .add() method, which I don't believe is cross-browser.