I have a question using grails variable values ββin javascript code in a GSP file.
For example: I have a session value session.getAttribute ("selectedValue") , and I want to use this value inside the javascript code part.
My solution now (inside GSP):
<% def js = new String("<script type=\"text/javascript\">") js += "var jsSelectedValue = " + session.getAttribute("selectedValue") + ";" js += "</script>" out << js %>
and then I have a javascript block inside my GSP with jQuery Stuff etc., I need this value.
Is there any other way to have grails variables available inside pure javascript code?
And the second question, quite the opposite. I select, for example, from the drop-down list and click "Save", and then I want to save the value of $ ("# select-box"). Val () inside the session variable from the JS part.
Thanks in advance for your help.
Greetings
Marco
source share