# Setting parameters in link from javascript

**URL:** <https://www.ruby-forum.com/t/setting-parameters-in-link-from-javascript/92798>\
**Category:** Rails\
**Created:** [April 24, 2007, 9:42am UTC](https://www.ruby-forum.com/t/setting-parameters-in-link-from-javascript/92798 "2007-04-24T09:42:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anders\_EngstrSSSSm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ecae2f/32.png) [@Anders\_EngstrSSSSm](https://www.ruby-forum.com/u/Anders_EngstrSSSSm)\
**Post date:** [April 24, 2007, 9:42am UTC](https://www.ruby-forum.com/t/setting-parameters-in-link-from-javascript/92798/1 "2007-04-24T09:42:43Z")

</div>

Hi.

I need to do an Ajax call to populate a span-tag with some text from  
the server-side. I’m using ‘link\_to\_remote’ but I need to fetch one of  
the parameters in the call from a form field.

Initially I tried something like:

\<%= link\_to\_remote ‘…’, :url =\> {:action =\> ‘some\_action’, :id =\> ‘$  
(some\_form\_field).value;’}, :update =\> ‘target\_span’ %\>

This will obviously not work.

But - is there an easy way to do this using the Rails helpers? I  
suppose it would be possibly by writing some custom Javascript - but  
I’m trying to avoid that.

Best Regards //Anders

---

<div class="post-metadata">

**Author:** ![Anders\_EngstrSSSSm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ecae2f/32.png) [@Anders\_EngstrSSSSm](https://www.ruby-forum.com/u/Anders_EngstrSSSSm)\
**Post date:** [April 24, 2007, 1:44pm UTC](https://www.ruby-forum.com/t/setting-parameters-in-link-from-javascript/92798/2 "2007-04-24T13:44:32Z")

</div>

I’ll go ahead and answer my own question 🙂

I managed to solve my specific problem by using the ‘submit’  
parameter:

\<%= link\_to\_remote ‘…’, :url =\> {:action =\> ‘some\_action’}, :update  
=\> ‘target\_span’, :submit =\> ‘id\_of\_container\_holding\_the\_input\_form’  
%\>

See [http://wiki.script.aculo.us/scriptaculous/show/Ajax.Updater](http://wiki.script.aculo.us/scriptaculous/show/Ajax.Updater) where  
the ‘submit’ parameter is described.

//Anders

---

<div class="post-metadata">

**Author:** ![Anders\_EngstrSSSSm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ecae2f/32.png) [@Anders\_EngstrSSSSm](https://www.ruby-forum.com/u/Anders_EngstrSSSSm)\
**Post date:** [May 1, 2007, 9:38pm UTC](https://www.ruby-forum.com/t/setting-parameters-in-link-from-javascript/92798/3 "2007-05-01T21:38:47Z")

</div>

That’s exactly what I was looking for!

I couldn’t find the description on the script.aculo.us-wiki. Could you  
(or anyone else) point me to a website where the usage of  
link\_to\_remote’s :submit-parameter is described? The rails API-docs  
arent very substantial regarding this…

My main-question is: How do I fetch the submitted parameter in the  
controller method? Using params[:submit]?
