How do you assign a JS variable to a Java variable in a JSP, or assign a Java variable to a JS variable?

Source: Internet
Author: User

In JSP often encounter the JS variable assigned to the Java variable, or the Java variable assigned to the JS variable case, here the general processing method summarized as follows:

Java variables passed to JS Good, var a= "<%=javaParam%>"; note to add the quotation marks "";

JS variable to java slightly more complex point, usually in the form with a
Hidden form elements, and then assigns the value of the JS variable to it in the script:

var jsparamvalue= ' aaaa ';
Form1.jsparam.value=jsparamvalue;

Then you can Request.getprameter ("Jsprama") to get the JS variable value.
You cannot assign a value to a Java variable on a page by taking a JS variable;
Instead, you can assign a Java variable to a JS variable with var jsparam = "<%=javaParam%>".

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.