# RJS with dynamic value passed into a link\_to\_function

**URL:** <https://www.ruby-forum.com/t/rjs-with-dynamic-value-passed-into-a-link-to-function/127899>\
**Category:** Rails\
**Created:** [February 2, 2008, 10:54am UTC](https://www.ruby-forum.com/t/rjs-with-dynamic-value-passed-into-a-link-to-function/127899 "2008-02-02T10:54:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ant](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/85e7bf/32.png) [@ant](https://www.ruby-forum.com/u/ant)\
**Post date:** [February 2, 2008, 10:54am UTC](https://www.ruby-forum.com/t/rjs-with-dynamic-value-passed-into-a-link-to-function/127899/1 "2008-02-02T10:54:53Z")

</div>

I would like to write a link\_to\_function that is dynamic in the sense  
that it inserts something into a div based on the value of a hidden  
field.

So at the moment I have

page.insert\_html :bottom, :div\_name, :partial =\>  
‘partial\_name’, :object =\> 5

I would like to do

page.insert\_html :bottom, :div\_name, :partial =\>  
‘partial\_name’, :object =\> value of a hidden form field

If it is not possible by the partial method, is it possible to have

page.insert\_html :bottom, :div\_name, html string

Where the html string contains some javascript that picks up  
the hidden field value.

I know how to do this with raw javascript but would love to do it in a  
cleaner rails/RJS fashion.

Thanks for any tips

Anthony

---

<div class="post-metadata">

**Author:** ![ant](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/85e7bf/32.png) [@ant](https://www.ruby-forum.com/u/ant)\
**Post date:** [February 2, 2008, 1:19pm UTC](https://www.ruby-forum.com/t/rjs-with-dynamic-value-passed-into-a-link-to-function/127899/2 "2008-02-02T13:19:06Z")

</div>

I encourage you to watch this podcast: [#45 RJS Tips - RailsCasts](http://railscasts.com/episodes/45)  
May be, it will be helpful
