I am wondering if it is possible to set embedded ruby variables in javascript. I've tried but to no avail. I'm thinking the javascript block won't recognize the <% %> erb tags.
What I want to do is basically call a javascript function from an onclick="setField('first_name')"
function setField(name)
{
<% fieldName = name %>
}
I don't think it's possible, because you are trying to put a javascript variable (name) into ruby, which I don't think it likes. Is there any possible way to do this. Or a confirmation that this cannot be done would be reassuring.
Thanks in advance