# Link\_to submit form value 2

**URL:** <https://www.ruby-forum.com/t/link-to-submit-form-value-2/152211>\
**Category:** Rails\
**Created:** [October 31, 2008, 10:38am UTC](https://www.ruby-forum.com/t/link-to-submit-form-value-2/152211 "2008-10-31T10:38:16Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![qwerty73](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/9d8465/32.png) [@qwerty73](https://www.ruby-forum.com/u/qwerty73)\
**Post date:** [October 31, 2008, 10:38am UTC](https://www.ruby-forum.com/t/link-to-submit-form-value-2/152211/1 "2008-10-31T10:38:16Z")

</div>

Hi to all,

I’d like to pass with a link to values inside some form. I’ve read in  
other posts that it’s possible if i include the forms inside a html

... So here it's my code of the view :

| Titolo di studio |
| Istituto | Data di conseguimento | Voto/giudizio |
| \<%= text\_field 'study', 'istituto'%\> | \<%= date\_select 'study', 'conseguito', {:include\_blank =\> true}%\> | \<%= text\_field 'study', 'voto'%\> |

\<%=link\_to “Aggiungi”, { :controller =\> “studies”, :action=\> “create”,  
:id\_nominee =\> @nominee.id, :study =\> @study}, :submit =\> ‘study’, :html  
=\> { :method =\> :post} %\>

where in submit value of Link\_to i’ve specified the div id.  
When i click on link\_to no forms values are passed…  
Can somebody help me???

---

<div class="post-metadata">

**Author:** ![qwerty73](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/9d8465/32.png) [@qwerty73](https://www.ruby-forum.com/u/qwerty73)\
**Post date:** [October 31, 2008, 10:47am UTC](https://www.ruby-forum.com/t/link-to-submit-form-value-2/152211/2 "2008-10-31T10:47:20Z")

</div>

On Oct 31, 9:38 am, Andrea C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Hi to all,
> 
> I’d like to pass with a link to values inside some form. I’ve read in  
> other posts that it’s possible if i include the forms inside a html
> 
> ...

That sounds made up to me. Links (without javascript help) don’t  
submit forms. if you have to have a link that submits a form, by far  
the easiest way is to have a link whose onclick is $  
(‘some\_form’).submit() (link\_to\_function makes this easy).

Fred

---

<div class="post-metadata">

**Author:** ![qwerty73](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/9d8465/32.png) [@qwerty73](https://www.ruby-forum.com/u/qwerty73)\
**Post date:** [October 31, 2008, 10:56am UTC](https://www.ruby-forum.com/t/link-to-submit-form-value-2/152211/3 "2008-10-31T10:56:20Z")

</div>

Frederick C. wrote:

> On Oct 31, 9:38ï¿½am, Andrea C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> wrote:
> 
> > Hi to all,
> > 
> > I’d like to pass with a link to values inside some form. I’ve read in  
> > other posts that it’s possible if i include the forms inside a html
> > 
> > ...
> 
> That sounds made up to me. Links (without javascript help) don’t  
> submit forms. if you have to have a link that submits a form, by far  
> the easiest way is to have a link whose onclick is $  
> (‘some\_form’).submit() (link\_to\_function makes this easy).
> 
> Fred

hi Fred,  
this is the topic [Submitting form with link\_to - Rails - Ruby-Forum](http://www.ruby-forum.com/topic/146247#new) where i’ve  
read the suggestion…  
So i was searching the right syntax for doing that, i’ll try to know  
more about link\_to\_function, but i’d like to know if it’s really  
possible in the other way, cause i’ve found more than one person that  
suggest that way…  
Tanks for your reply

Andrea

---

<div class="post-metadata">

**Author:** ![qwerty73](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/9d8465/32.png) [@qwerty73](https://www.ruby-forum.com/u/qwerty73)\
**Post date:** [October 31, 2008, 2:57pm UTC](https://www.ruby-forum.com/t/link-to-submit-form-value-2/152211/4 "2008-10-31T14:57:33Z")

</div>

Andrea C. wrote:

> \<%=link\_to “Aggiungi”, { :controller =\> “studies”, :action=\> “create”,  
> :id\_nominee =\> @nominee.id, :study =\> @study}, :submit =\> ‘study’, :html  
> =\> { :method =\> :post} %\>
> 
> where in submit value of Link\_to i’ve specified the div id.  
> When i click on link\_to no forms values are passed…  
> Can somebody help me???

I am doing the exact thing that you are asking about the only difference  
is that I am using a link\_to\_remote, here is my code:

\<%= link\_to\_remote(‘Save’,  
{:submit =\> “car\_prefs”, :update =\> ‘account\_car\_prefs’,  
:complete =\> ‘new Effect.Pulsate(‘account\_car\_prefs’);’,  
:url =\> {:action =\> ‘car\_prefs’, :id =\> @account.id}},  
:class =\> “squarebutton”) %\>

My car\_prefs div encapsulates all the textfields and dropdowns and then  
the :complete just updates another div - account\_car\_prefs - when the  
action has completed. You might also try looking at the source to make  
sure that the html is being generated properly, I say this because it  
seems more often then not, for me, that I always get the { } put in the  
wrong place when using additional options and you can also tell if you  
are using them wrong because the html doesn’t get formed right.

-S

---

<div class="post-metadata">

**Author:** ![qwerty73](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/9d8465/32.png) [@qwerty73](https://www.ruby-forum.com/u/qwerty73)\
**Post date:** [October 31, 2008, 11:31am UTC](https://www.ruby-forum.com/t/link-to-submit-form-value-2/152211/5 "2008-10-31T11:31:56Z")

</div>

On 31 Oct 2008, at 09:56, Andrea C. wrote:

> > > ...
> > > 
> > > i’ve  
> > > read the suggestion…
> > > 
> > > That’s just wrong. Probably confused by the fact that link\_to\_remote  
> > > does take a :submit option (which should be the id of a form element)
> > > 
> > > Fred
> > > 
> > > > So i was searching the right syntax for doing that, i’ll try to know  
> > > > more about link\_to\_function, but i’d like to know if it’s really  
> > > > possible in the other way, cause i’ve found more than one person that  
> > > > suggest that way…  
> > > > Tanks for your reply

---

<div class="post-metadata">

**Author:** ![qwerty73](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/9d8465/32.png) [@qwerty73](https://www.ruby-forum.com/u/qwerty73)\
**Post date:** [October 31, 2008, 4:42pm UTC](https://www.ruby-forum.com/t/link-to-submit-form-value-2/152211/6 "2008-10-31T16:42:15Z")

</div>

On 31 Oct 2008, at 15:19, Andrea C. wrote:

> > then  
> > -S
> 
> Hi Shandy,
> 
> really thanks for your reply… NOw it works!!!  
> I was really SAD for the first answer 😃 now i’m better

Just so you’re aware, the above does rely on javascript and the  
prototype libraries - it won’t work without javascript.

Fred

---

<div class="post-metadata">

**Author:** ![qwerty73](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/9d8465/32.png) [@qwerty73](https://www.ruby-forum.com/u/qwerty73)\
**Post date:** [October 31, 2008, 4:19pm UTC](https://www.ruby-forum.com/t/link-to-submit-form-value-2/152211/7 "2008-10-31T16:19:48Z")

</div>

Shandy N. wrote:

> \<%= link\_to\_remote(‘Save’,  
> {:submit =\> “car\_prefs”, :update =\> ‘account\_car\_prefs’,  
> :complete =\> ‘new Effect.Pulsate(‘account\_car\_prefs’);’,  
> :url =\> {:action =\> ‘car\_prefs’, :id =\> @account.id}},  
> :class =\> “squarebutton”) %\>
> 
> My car\_prefs div encapsulates all the textfields and dropdowns and then  
> the :complete just updates another div - account\_car\_prefs - when the  
> action has completed. You might also try looking at the source to make  
> sure that the html is being generated properly, I say this because it  
> seems more often then not, for me, that I always get the { } put in the  
> wrong place when using additional options and you can also tell if you  
> are using them wrong because the html doesn’t get formed right.
> 
> -S

Hi Shandy,

really thanks for your reply… NOw it works!!!  
I was really SAD for the first answer 😃 now i’m better
