Forms

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

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

To take that one step more, it would be <a href="#" onclick="$ ('my_form').submit(); return false;">Submit the form</a>