Daniel Legrand
2007-Jun-28 17:50 UTC
Submitting a form without clicking the submit button?
I''m using AJAX with 2 select pulldowns. When you select an item in the first pulldown, it dynamically populates the second pulldown. However, I need to value of the first select pulldown to know how to populate the second pulldown. When I select an element in the first pulldown, and submit via clicking the submit button, it posts the value as needed and sends in in the params hash. I''m trying to get the selected value to return via the params hash but to do so "onchange" instead of by clicking the submit button. Does anyone know how to submit a form without having the user click the button? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Bill Walton
2007-Jun-28 18:33 UTC
Re: Submitting a form without clicking the submit button?
Hi Daniel, Daniel Legrand wrote:> I''m using AJAX with 2 select pulldowns. When you select an item in the > first pulldown, it dynamically populates the second pulldown. However, > I need to value of the first select pulldown to know how to populate the > second pulldown. When I select an element in the first pulldown, and > submit via clicking the submit button, it posts the value as needed and > sends in in the params hash. I''m trying to get the selected value to > return via the params hash but to do so "onchange" instead of by > clicking the submit button. Does anyone know how to submit a form > without having the user click the button?You don''t submit the form. Use observe_field to submit the change to the first pulldown, then RJS to render the second. There''s been quite a bit of discussion here about how to use observe_field with select boxes and I''m sure you can Google it up. hth, Bill --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Daniel Legrand
2007-Jun-28 18:54 UTC
Re: Submitting a form without clicking the submit button?
Thanks Bill. I just figured it out a few minutes ago. I wasn''t sure if the method I chose was appropriate, but it looks like it is. Again, thanks for your help! Bill Walton wrote:> Hi Daniel, > > Daniel Legrand wrote: > >> I''m using AJAX with 2 select pulldowns. When you select an item in the >> first pulldown, it dynamically populates the second pulldown. However, >> I need to value of the first select pulldown to know how to populate the >> second pulldown. When I select an element in the first pulldown, and >> submit via clicking the submit button, it posts the value as needed and >> sends in in the params hash. I''m trying to get the selected value to >> return via the params hash but to do so "onchange" instead of by >> clicking the submit button. Does anyone know how to submit a form >> without having the user click the button? > > You don''t submit the form. Use observe_field to submit the change to > the > first pulldown, then RJS to render the second. There''s been quite a bit > of > discussion here about how to use observe_field with select boxes and I''m > sure you can Google it up. > > hth, > Bill-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Bill Walton
2007-Jun-28 20:12 UTC
Re: Submitting a form without clicking the submit button?
Daniel Legrand wrote:> > Thanks Bill. I just figured it out a few minutes ago. I wasn''t sure if > the method I chose was appropriate, but it looks like it is. Again, > thanks for your help!You''re welcome! Bill --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---