# Submit form using a link instead of a button

**URL:** <https://www.ruby-forum.com/t/submit-form-using-a-link-instead-of-a-button/125561>\
**Category:** Rails\
**Created:** [January 10, 2008, 4:11am UTC](https://www.ruby-forum.com/t/submit-form-using-a-link-instead-of-a-button/125561 "2008-01-10T04:11:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![fries88](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/6bbea6/32.png) [@fries88](https://www.ruby-forum.com/u/fries88)\
**Post date:** [January 10, 2008, 4:11am UTC](https://www.ruby-forum.com/t/submit-form-using-a-link-instead-of-a-button/125561/1 "2008-01-10T04:11:32Z")

</div>

Hi,

Which form should I use? I am currently using form\_for.Is it the right  
form to use? What I am supposed to do in the form is to save the various  
fields and go to the next page when i click the link which i am going to  
name next. I am now using \<%= link\_to\_function ‘Next’,  
“$(‘form\_id’).submit(0)” %\> to create the link. 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| %\>

There is an error when I press submit.Can someone tell me the right way  
to do this?

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()?

Thanks,  
fries88

---

<div class="post-metadata">

**Author:** ![fries88](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/6bbea6/32.png) [@fries88](https://www.ruby-forum.com/u/fries88)\
**Post date:** [January 10, 2008, 4:13pm UTC](https://www.ruby-forum.com/t/submit-form-using-a-link-instead-of-a-button/125561/2 "2008-01-10T16:13:30Z")

</div>

I think that should be

\<%= link\_to\_function ‘Submit’, “$(‘prod’).submit()” %\>

and not

\<%= link\_to\_function ‘Submit’, “$(‘form\_id’).submit(0)” %\>

view source to make sure the tag has id=“prod” as you  
intended. also you may want to call it product\_form or something less  
likely to conflict with something else.

---

<div class="post-metadata">

**Author:** ![fries88](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/6bbea6/32.png) [@fries88](https://www.ruby-forum.com/u/fries88)\
**Post date:** [January 11, 2008, 2:37am UTC](https://www.ruby-forum.com/t/submit-form-using-a-link-instead-of-a-button/125561/3 "2008-01-11T02:37:08Z")

</div>

rubynuby wrote:

> I think that should be
> 
> \<%= link\_to\_function ‘Submit’, “$(‘prod’).submit()” %\>
> 
> and not
> 
> \<%= link\_to\_function ‘Submit’, “$(‘form\_id’).submit(0)” %\>
> 
> view source to make sure the tag has id=“prod” as you  
> intended. also you may want to call it product\_form or something less  
> likely to conflict with something else.

Hi,

I have checked to sure the tag has id=“prod”. But it doesn’t. I  
am currently using form\_for. And I’ve tried ways to set the id. But it  
does work. Can anyone teach me how to set the id for form\_for?

Thanks  
fries 88

---

<div class="post-metadata">

**Author:** ![fries88](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/6bbea6/32.png) [@fries88](https://www.ruby-forum.com/u/fries88)\
**Post date:** [January 11, 2008, 2:42am UTC](https://www.ruby-forum.com/t/submit-form-using-a-link-instead-of-a-button/125561/4 "2008-01-11T02:42:05Z")

</div>

:html =\> { :id =\> “here” }

On Jan 11, 2008 12:07 PM, user splash [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> > view source to make sure the tag has id=“prod” as you
> 
> ## Thanks fries 88
> 
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> >

–  
Ryan B.

> **[frozenplague.net](http://www.frozenplague.net)**
>
> This domain may be for sale!

Feel free to add me to MSN and/or GTalk as this email.
