dcsimg

How can I set a JavaScript variable from within a JSP page?

Vasu devan

You can pass the value of a Java variable to a hidden field in a JSP as:

<INPUT TYPE=HIDDEN NAME=JSCRIPTVAR VALUE='<%= javavar %>'>

and use the JavaScript variable inside javascript,

<SCRIPT>
if(JSCRIPTVAR == 100)......
</SCRIPT>