Evaluate ruby code inside javascript

Hi
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

Sijo Kg wrote:

Hi
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

You’re mixing javascript with ruby as far as I can see.
You can’t ‘call’ js functions as long as your code runs on the server
(ruby code)
The js stuff (vars etc) is only available in the browser. Same goes for
dom object methods like value.
So div_no won’t be available to ruby.

get_primary_assignees_transfer_reason($(‘transfer_reason’ +
div_no))’).value)

should work in the browser. but will never work on the server.

On 2 Jun 2008, at 11:29, Sijo Kg wrote:

assuming div_no is a javascript variable, that should be $
(‘transfer_reason’ + div_no)

Fred