# evaluate ruby code inside javascript

**URL:** <https://discuss.rubyonrails.org/t/evaluate-ruby-code-inside-javascript/30094>\
**Category:** rubyonrails-talk\
**Created:** [June 2, 2008, 10:29am UTC](https://discuss.rubyonrails.org/t/evaluate-ruby-code-inside-javascript/30094 "2008-06-02T10:29:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![11175](https://avatars.discourse-cdn.com/v4/letter/1/8edcca/32.png) [@11175](https://discuss.rubyonrails.org/u/11175)\
**Post date:** [June 2, 2008, 10:29am UTC](https://discuss.rubyonrails.org/t/evaluate-ruby-code-inside-javascript/30094/1 "2008-06-02T10:29:08Z")

</div>

Hi &nbsp;&nbsp;&nbsp;I was trying to call a javascript function.I have text areas like transfer\_reason1 transfer\_reason2 etc in each divs div number is available as variable div\_no in the page..How can I pass the textarea content to the javascript..Below I tried like get\_primary\_assignees\_transfer\_reason($('transfer\_reason+eval(#{div\_no}))').value )

How can I evaluate the above to get get\_primary\_assignees\_transfer\_reason($('transfer\_reason1').value ) get\_primary\_assignees\_transfer\_reason($('transfer\_reason2').value ) etc But not working.Please help

Sijo

---

<div class="post-metadata">

**Author:** ![Frederick\_Cheung](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/frederick_cheung/32/3901_2.png) [@Frederick\_Cheung](https://discuss.rubyonrails.org/u/Frederick_Cheung)\
**Post date:** [June 2, 2008, 10:41am UTC](https://discuss.rubyonrails.org/t/evaluate-ruby-code-inside-javascript/30094/2 "2008-06-02T10:41:08Z")

</div>

> Hi &nbsp;&nbsp;I was trying to call a javascript function.I have text areas like transfer\_reason1 transfer\_reason2 etc in each divs div number is available as variable div\_no in the page..How can I pass the textarea content to the javascript..Below I tried like get\_primary\_assignees\_transfer\_reason($('transfer\_reason +eval(#{div\_no}))').value )

assuming div\_no is a javascript variable, that should be $ ('transfer\_reason' + div\_no)

Fred
