Hello, Can I pass a variable from a submit button only? I have a form that the user fills out and I need two different submit buttons - one for ''sync'' and one for ''full push''. I was thinking I could add some sort of param to the button, but it''s not working... is there a way to do this? I have this: <%= submit_tag ''push to Exchange'', :name => "rad", :id => "0", :onclick => "doClick(this)" %> <%= submit_tag ''force full push'', :name => "radtwo", :full => "full", :onclick => "doClick(this)" %> I tried to add param[:full], but it doesn''t work. Any suggestions? Thanks, - Jeff Miller -- 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 -~----------~----~----~----~------~----~------~--~---
check your params--you might find it''s already in there. On Wed, Apr 30, 2008 at 1:57 PM, Jeff Miller <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Hello, > Can I pass a variable from a submit button only? I have a form that the > user fills out and I need two different submit buttons - one for ''sync'' > and one for ''full push''. I was thinking I could add some sort of param > to the button, but it''s not working... is there a way to do this? I have > this: > > <%= submit_tag ''push to Exchange'', :name => "rad", :id => "0", :onclick > => "doClick(this)" %> > > <%= submit_tag ''force full push'', :name => "radtwo", :full => "full", > :onclick => "doClick(this)" %> > > I tried to add param[:full], but it doesn''t work. Any suggestions? > > Thanks, > - Jeff Miller > -- > 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 -~----------~----~----~----~------~----~------~--~---
On Apr 30, 2008, at 3:57 PM, Jeff Miller wrote:> Hello, > Can I pass a variable from a submit button only? I have a form that > the > user fills out and I need two different submit buttons - one for > ''sync'' > and one for ''full push''. I was thinking I could add some sort of param > to the button, but it''s not working... is there a way to do this? I > have > this: > > <%= submit_tag ''push to Exchange'', :name => "rad", :id => > "0", :onclick > => "doClick(this)" %> > > <%= submit_tag ''force full push'', :name => "radtwo", :full => "full", > :onclick => "doClick(this)" %> > > I tried to add param[:full], but it doesn''t work. Any suggestions? > > Thanks, > - Jeff MillerUnless you gave a :name => nil option to your submit_tag, you can test params[:commit] for the button label (or, I think, supply your own :value => ''sync'' or :value => ''full'') I''ve used this to give both a "Create" and a "Create and Add Child" button to a form that changed where you were redirected on success. -Rob Rob Biedenharn http://agileconsultingllc.com Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I''m a newbie myself, but suspect that submit_tag can not be made to do this. To pass arbitrary parameters to your controller from a form you specify them on the form_for call. One option that comes to mind is to give the user a drop-down to select which of the two types of submits they want to do. I don''t suppose that appeals? -----Original Message----- From: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org [mailto:rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org] On Behalf Of Jeff Miller Sent: Wednesday, April 30, 2008 12:57 PM To: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Subject: [Rails] Quick Submit Button Question... Hello, Can I pass a variable from a submit button only? I have a form that the user fills out and I need two different submit buttons - one for ''sync'' and one for ''full push''. I was thinking I could add some sort of param to the button, but it''s not working... is there a way to do this? I have this: <%= submit_tag ''push to Exchange'', :name => "rad", :id => "0", :onclick => "doClick(this)" %> <%= submit_tag ''force full push'', :name => "radtwo", :full => "full", :onclick => "doClick(this)" %> I tried to add param[:full], but it doesn''t work. Any suggestions? Thanks, - Jeff Miller -- 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
><%= submit_tag ''force full push'', :name => "radtwo", :full => "full", >:onclick => "doClick(this)" %>You should specify params[:full] at function doClick(this). But if you put 2 submit_tag buttons there, it''s nasty way. Another way is : <%= submit_tag ''push to Exchange'', :name => "rad", :id => "0", :onclick => "doClick(this)" %> <%= button_to_function ''force full push'', {:name => "radtwo", :full => "full"}, :onclick => "doClick(this)" %> Another way is : <%= button_to "push to Exchange", {:action=>''go'',:name => "rad", :id => "0"}, :onclick => "doClick(this)" %> <%= button_to "force full push", {:action => ''where'', :name => "radtwo", :full => "full"}, :onclick => "doClick(this)" %> Reference : http://railsmanual.org/module/ActionView::Helpers::UrlHelper/button_to/1.1.2 Good Luck Reinhart http://teapoci.blogspot.com -- 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 -~----------~----~----~----~------~----~------~--~---
Thanks guys, I ended up passing it through Javascript, like the last suggestion. And yes, it turns out that HTML submit buttons cannot pass variables themselves, as they just initiate the post. Thanks again, - Jeff Miller -- 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 -~----------~----~----~----~------~----~------~--~---