# Dynamic parameters in link\_to

**URL:** <https://www.ruby-forum.com/t/dynamic-parameters-in-link-to/107135>\
**Category:** Rails\
**Created:** [June 18, 2007, 3:25pm UTC](https://www.ruby-forum.com/t/dynamic-parameters-in-link-to/107135 "2007-06-18T15:25:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gattox](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/4491bb/32.png) [@gattox](https://www.ruby-forum.com/u/gattox)\
**Post date:** [June 18, 2007, 3:25pm UTC](https://www.ruby-forum.com/t/dynamic-parameters-in-link-to/107135/1 "2007-06-18T15:25:58Z")

</div>

Don’t know how to use a link\_to directive where one of the parameters is  
taken form a form field (client side), eg:

…

# 

# The field “numrows” is used to dynamically change the number of rows

per page

# in a pager (ok, let apart will\_paginate and other paginate plugins)

# 

#Rows per Page :   
\<%= text\_field\_tag “numrows”, session[:nr] || Customer.per\_page, :size  
=\> 5 %\>  
\<%= link\_to ‘Change #Rows per Page’, {:action =\> ‘set\_row\_per\_page’,  
:rowsperpage =\> \<would like to pass here the content of “numrows”  
field\>, :method =\> :post, :class =\> “IsALink” %\>

Note that “numrows” is a non-model field of the form.

How can i dynamically set the value of “:rowsperpage” so that clicking  
on the link will restart pagination with a differente number of rows  
per page. I need to know how to dynamically set up the value of the  
parameter using something link $(‘numrows’).value

Any help appreciated.

---

<div class="post-metadata">

**Author:** ![gattox](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/4491bb/32.png) [@gattox](https://www.ruby-forum.com/u/gattox)\
**Post date:** [June 18, 2007, 5:49pm UTC](https://www.ruby-forum.com/t/dynamic-parameters-in-link-to/107135/2 "2007-06-18T17:49:26Z")

</div>

You will need to use client side javascript to construct the value  
you want to pass. You need to use link\_to\_function to make the link  
call javascript, compute the URL including parameters, then either  
fetch or redirect to that URL.

Michael
