How one can use a JS variable in the ruby code?
Depends what you mean. if you want a link or similar to submit a
javascript variable then have a look at
http://www.spacevatican.org/2008/5/17/with-or-without-you-link_to_remote-s-mysterious-parameter
Fred
Have you figured this out yet? I am looking for the same thing. How
would you set a ruby variable inside a javascript method? Say something
like this...
<SCRIPT language="JavaScript">
function submitform(nextQuestion)
{
<% @nextQuestion = nextQuestion %>
document.form1.submit();
}
</SCRIPT>
Thanks
Have you figured this out yet? I am looking for the same thing. How
would you set a ruby variable inside a javascript method? Say something
like this...<SCRIPT language="JavaScript">
function submitform(nextQuestion)
{
<% @nextQuestion = nextQuestion %>
document.form1.submit();
That's completely impossible - client side code cannot have server
side effects (except of course via a request of some sort). If you
are trying to change what the form submits, then a classic technique
is to have a hidden field on the form that the javascript manipulates.
Fred