简体   繁体   中英

Java variables inside Javascript

I have a variable declared outside my javascript function which gets its value from session.

   String elementID = session.getAttribute("elementID");
   <SCRIPT>
        var a = "123"
        elementID = a;
   </SCRIPT>

Will this work out? i need to assign the value "123" to the string variable elementID.

This is not simply possible, since Java runs server-side and JavaScript client-side.

You can't assume that the JavaScript (that won't be evaluated until it's on the client) knowns anything about Java. It doesn't.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM