Hmm.  I wrote a response, but it hasn't appeared - RobG posted while I
was writing it, and I suspect it didn't get posted for that reason.

Anyway, I basically talked about the same things RobG has said - that
add() needs to args, the second being a reference to the option which
the new option will be placed right before, and IE needs that argument
as an integer rather than an object like everybody else.  So a code
snippet for inserting a new option into a select element at a specific
position across browsers might look something like this:

var sel = $("TheSelectBox");
var nextOpt = document.all? (code to create an integer for IE) : (code
to get an Option object);
sel.add(new Option("apple",1),nextOpt);

And if you want it at the end of the list, nextOpt should be null.

My problem's solved, then.  I can use this to insert new options while
maintaining alphabetical order within the list.  Thanks for the help,
people.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on 
Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to