Submit a form using a link

Re: Submit a form using a link
Posted by fries 88 (fries88) on 10.01.2008 03:42
Jeremy Weiskotten wrote:

Brian Hogan wrote:

Why do you want to use a link? It's really not such a good idea, as
are generally used to using a button.

If it's an absolute requirement, the approach I have always taken is to
apply CSS to the button to make it look like a link.

Other solutions involve making the link call a javascript function that
submits the form. Yuk.

<%= link_to_function 'Submit', "$('form_id').submit()" %>

But yeah, yuk. Stick with a button unless there's a good reason for a
link (design-wise).

Hmm...So which form should i use? I am supposed to save the various
fields and go to the next page when i click the link which i am going to
name next. I have tried to give the form_for an id by doing this:

<% form_for :e0_1_prod_desc,:id => 'prod', :url => { :action =>
:save_prod_desc } do |n| %>

Is it the right way? And i just saw from somewhere,
<%= link_to_function 'Submit', "$('form_id').submit(0)" %>

Why is submit(0)? What is the difference between submit(0) and submit()?