Topic: Submitting a form - variations..


I have a remote form which i submit using 'onsubmit()' from two
different links in my view. I understand that html limits us to only
executing a single action when a form is submitted - however i would
like to distinguish between which of the links the form has been
submitted from..

This is an example of one of the two links that submit my form:

<= link_to_remote 'link', :before => "javascript:myform.onsubmit()" %>

Is there a way to pass the form a parameter using this javascript call
to submit the form?

The only way i can think of is to update a value in the database in the link_to and then check for this value (boolean) - in the controller method that is called when the form is submitted.. seems very messy..

any ideas??


Re: Submitting a form - variations..

You can set a hidden field when clicking a link:

<%= hidden_field_tag 'do_something' %>
<%= link_to_function 'submit and do something', '$('do_something').value = 1;myform.onsubmit();" %>


Railscasts - Free Ruby on Rails Screencasts