ASP JavaScript value of the mutual transfer method _ application skills

Source: Internet
Author: User
If you can understand my following words well, then none of this is a problem.
ASP is a server-side language, its role is to dynamically generate the client browser can recognize the HTML CSS JavaScript, etc. ...
So how does the ASP pass the value to JS?
The dynamic to generate JS is good ~ ~ How do we generate HTML?
Isn't that right?
Program code
<table>
<%do While not rs.eof%>
<tr><td>
<a href=<%=rs ("id")%>><%=rs ("name")%></a>
</td></tr>
<%rs.movenext
Loop%>
</table>
How do I generate the name value? <%=rs ("name")%> so how to generate the values in JS?
For example, a JS variable js_name to get the value of the variable asp_name in the ASP
to build.
<script>
Js_name=<%=asp_name%>
</script>
and generate HTML no different, the same,
CSS can also generate VBScript VML or even XML can be dynamically generated, and generate HTML without distinction.
If you understand the above, the ASP pass the value to JS is no problem.
The following JS transfer value to the ASP
How does HTML pass value to the ASP? Two common methods are form submission and suffix of URL followed to pass value
JS is the same, form submit URL suffix
Examples such as
form submission, the JS variable is first assigned to an input
<script>
Document.form1.inputx.value=js_name
</script>
Then Form1.submit (), submit the form
Examples such as
URL Pass value,
<script>
window.open ("Www.blueidea.com/index.asp?asp_name=" +js_name)
</script>
It's the same thing as the HTML principle, because js/html are all client-side stuff.
There is also a way to allow js-asp to pass each other's value, that is, through cookies
ASP can set a cookie-> a1=111
JS in the value of cookies, you can use the Document.cookie in JS to get all the cookie value
And then by proper interception, you get a A1 value of 111.
In the same JS to set the a1=111,asp can also read the correct value of this cookie
Above:
The same applies to asp/jsp/php/.... Values for all server-side languages with Js/vbs

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.