Mutual transmission of JS and Java Variables

Source: Internet
Author: User

Mutual transmission of JS and Java Variables

In JSP, JS variables are often assigned to Java variables, or Java variables are assigned to JS variables. Here we will summarize the general processing methods as follows:

 

It is easy to pass the Java variable to JS. var A = "<% = javaparam %>"; note that you must add the quotation marks;

 

JS variables are a little complex for Java. Generally,

And then assign the JS variable value to it in the script:

 

VaR jsparamvalue = 'aaa ';

Form1.jsparam. value = jsparamvalue;

 

Then you can request. getprameter ("jsprama"); To Get The JS variable value.

 

Supplement: Ajax is actually a real-time technology that transfers JS variables to the server without refreshing the page.

 

Summary:

You cannot assign values to Java variables on the page using JS variables;

Instead, you can use VaR jsparam = "<% = javaparam %>" to assign the Java variable to the JS variable.

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.