passing variables between javascript and JSP
i have a variable in jsp named "var" and i would like to assign to it a value from a java script .
How could i do this?
here is the code
<%
String var="firstletter"+ %><script>ar['0']</script><% +"the last letter";
%>
where ar['0'] is a java script array read from a java script file included as
<script src='ar1.js'>
</script>
in the header of the JSP
thanks in advance
Hi,
If you want to assign the value from javascript to jsp, either you have to pass that value to jsp or you have to put that value in httpsession. For this situation you have to pass that javascript value to jsp and use it .
Hope that helps.
Best Luck,
Senthil Babu
Developer Technical Support
SUN Microsystems
http://www.sun.com/developers/support/
> you can give it a try by sending jsp variables to
> javascript
>
> ex.
> <%
> jsp_variables=rs.getthing("whatever");
> %>
> <script>
> var js_variables;
> if(js_variables==<%=jsp_variables%>){
> .
> .
> }
> </script>
This is axactley what I do. Pass it like that.