Make a link behave like a form submit button

Hi all,

I was wondering if it was possible to have a link that behaves like a
form submit button? I’ve tried using a link_to with a post method, but
it does not perform the same action as a form submit. The action
specified in the link_to is called, by the parameters from the form
are not populating params.

Is this possible? Any help would be appreciated.

Thanks in advance.


It’s possible, but you’ll have to submit using javascript.

For example:

<%= link_to_function ‘Submit’, “$(‘my_form_id’).submit(0)” -%>

Hi Grejan,

That worked perfectly. Thank you.


On Oct 24, 10:53 pm, Gerjan S. <rails-mailing-l…@andreas-

Hi Diego,

I want to know what kind of form you had used? Is it form, form_for,
form_remote_tag or something else. As you see I am a beginner and had
tried to give my form_for an id but it didnt work.

I really hope that you could help me.

Thank you,