a.rebholz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Nov-16 18:16 UTC
Reseting a select box
Hello, is there a way to reset a select box to it''s default value? Or do I habe to use update() on the select box to empty it and then add all the options again? TIA, Alex --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Hi, actually you just need to find out which is the default value of your select box and then select this via script. I use the following code for it: <--snip--> for (var i=0;i<sel.options.length;i++) { sel.options[i].selected = sel.options[i].defaultSelected; } <--snip--> Add this to you "resetMySelectBox(sel)"- function and you''ll be happy ;o) hf Bastian On Nov 16, 2007 7:16 PM, <a.rebholz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hello, > > is there a way to reset a select box to it''s default value? > > Or do I habe to use update() on the select box to empty it and then add all > the options again? > > TIA, > Alex > > > >-- -- spread the word ... see www.browsehappy.com ;o) Calvin: Weekends don''t count unless you spend them doing something completely pointless. Join the Greater IBM Connection (http://www.xing.com/premiumgroup-6291.d26b7d) --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
a.rebholz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Nov-17 01:13 UTC
Re: Reseting a select box
Bastian, DOH! Sometimes I should recall the orginal javascript possibilities. As I have several select boxes and the first option is always the default option I used the following solution: $$(''fieldset#ep4hd select'').each(function(s){s.selectedIndex = 0;}) Anyway thanks again. Alex 2007/11/16, Bastian Feder <bastian.feder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> > > Hi, > actually you just need to find out which is the default value of your > select box and then select this via script. > I use the following code for it: > > <--snip--> > > for (var i=0;i<sel.options.length;i++) { > sel.options[i].selected = sel.options[i].defaultSelected; > } > > <--snip--> > > Add this to you "resetMySelectBox(sel)"- function and you''ll be happy ;o) > > hf > Bastian > > > On Nov 16, 2007 7:16 PM, <a.rebholz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Hello, > > > > is there a way to reset a select box to it''s default value? > > > > Or do I habe to use update() on the select box to empty it and then add > all > > the options again? > > > > TIA, > > Alex > > > > > > > > > > > -- > -- > spread the word ... see www.browsehappy.com ;o) > > Calvin: Weekends don''t count unless you spend them doing something > completely pointless. > > Join the Greater IBM Connection ( > http://www.xing.com/premiumgroup-6291.d26b7d) > > > >--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---