Help - Search - Members - Calendar
Full Version: Javascript Insert Drop Down Options (Before) Option
HTMLHelp Forums > Programming > Client-side Scripting
mathceleb
I have a drop down menu where I need to insert options before a certain option. The method I use now is:

CODE
s.options[36]=new Option("FE", "FE(F)", false, false);


But what if the index 36 is variable based on where I want to insert. How do I insert before an option already on the list. The method I use above wipes out the option that was in index 36.
Christian J
With the DOM you can both create the OPTION element and insert it before that other option.

See e.g. http://www.javascriptkit.com/javatutors/dom.shtml and http://www.quirksmode.org/dom/w3c_core.html
mathceleb
QUOTE(Christian J @ May 19 2009, 10:00 AM) *

With the DOM you can both create the OPTION element and insert it before that other option.

See e.g. http://www.javascriptkit.com/javatutors/dom.shtml and http://www.quirksmode.org/dom/w3c_core.html


That is great, thanks for the links!
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.