Is there a way to trigger a submit of a form by a link outside of the form. For example: <% form_tag do %> <tr> <td> <label for="name">Name:</label> <%= text_field_tag :name, params[:name] %> </td> <td> <label for="password">Password:</label> <%= password_field_tag :password, params[:password] %> </td> </tr> <tr> <td> <%= submit_tag "Login" %> </td> </tr> <% end %> Instead of having the submit button which is located inside of the <% form_tag do %> <% end %> is it possible to place a link after the <% end %> which will trigger the submit of the form. I am trying to keep things consistent on a project I am working on and all the navigation from one page to the next is done with a link located in the layout. I would like to keep this the same but have a form in one of the views with no submit button. Any suggestions? The code above is not the actual example, I just thought something visual would help explain. Thanks in advance -- 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 13 Mar 2008, at 19:10, Chris Hickman wrote:> > Is there a way to trigger a submit of a form by a link outside of the > form. For example: > > > Instead of having the submit button which is located inside of the <% > form_tag do %> <% end %> is it possible to place a link after the <% > end > %> which will trigger the submit of the form. >You can with javascript: $(''my_form'').submit(); Fred> I am trying to keep things consistent on a project I am working on and > all the navigation from one page to the next is done with a link > located > in the layout. I would like to keep this the same but have a form in > one of the views with no submit button. Any suggestions? > > The code above is not the actual example, I just thought something > visual would help explain. > > Thanks in advance > -- > 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 > -~----------~----~----~----~------~----~------~--~--- >
To take that one step more, it would be <a href="#" onclick="$ (''my_form'').submit(); return false;">Submit the form</a> On Mar 13, 12:34 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 13 Mar 2008, at 19:10, Chris Hickman wrote: > > > > > Is there a way to trigger a submit of a form by a link outside of the > > form. For example: > > > Instead of having the submit button which is located inside of the <% > > form_tag do %> <% end %> is it possible to place a link after the <% > > end > > %> which will trigger the submit of the form. > > You can with javascript: $(''my_form'').submit(); > > Fred > > > I am trying to keep things consistent on a project I am working on and > > all the navigation from one page to the next is done with a link > > located > > in the layout. I would like to keep this the same but have a form in > > one of the views with no submit button. Any suggestions? > > > The code above is not the actual example, I just thought something > > visual would help explain. > > > Thanks in advance > > -- > > Posted viahttp://www.ruby-forum.com/. > > > > > > > smime.p7s > 5KDownload--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---