Mutual reading of variable values between html javascript jsp

Source: Internet
Author: User

Javascript html read from each other

Javascript --> html:

For example:

Taoba

Reference Method on the same page:

1. Use id:

Link1.href, return a http://homepage.yesky.com

2. Use name:

Document. all. linkname1.href, return a http://homepage.yesky.com

3. Use sourseIndex:

Document. all (4). href // note that there are HTML, HEAD, TITLE, and BODY in front, so it is 4

4. Use a link set:

Document. anchors [0]. href

// All sets include all, anchors, applets, areas, attributes, behaviorUrns, bookmarks, boundElements, cells, childNodes,

Children, controlRange, elements, embeds, filters, forms, frames, images, imports, links, mimeTypes, options,

For details about plugins, rows, rules, scripts, styleSheets, tBodies, and TextRectangle, see MSDN.

In fact, method 3 and method 4 use the same set, but one is all, which can include all the tags on the page, while anchors only includes links.

5. getElementById:

Document. getElementById ("link1"). href

6. getElementsByName:

Document. getElementsByName ("linkname1") [0]. href // This is also a set of tags whose names are equal to the parameters included in the method.

7. getElementsByTagName:

Document. getElementsByTagName ("A") [0]. href // This is also A set of all tags whose names are equal to the parameters included in the Method

8. tags set:

Document. all. tags ("A") [0]. href

// Like Method 7, a set is obtained by Tag name.

Reference: http://www.360doc.com/content/12/0331/13/9249789_199598292.shtml


Html --> javascript:




Html jsp read from each other

Jsp --> html:

Html page form

In the form, action and method are combined to send the data to the mujsp. jsp page for processing. On the jsp page

Http://blog.csdn.net/coslay/article/details/ <% request. getParmerter ("data"); %> get the data passed from the html page


Html --> jsp:

"Id =" link1 "name =" linkname1 ">


Javascript jsp mutual reading

Javascript --> jsp:

<Script type = "text/javascript">

Var businessType = '<% = businessType %> ';

</Script>

'<% = BusinessType %>' must be enclosed in quotation marks. Otherwise, the type conversion will occur, resulting in unexpected values.


Jsp --> javascript:

1.

Var username = 'sa ';

Document. forms [0]. action = "loign. action? Username "+ username;

You can use request. getParameter ("username") in the background action ");

2. You can use hidden domains ..

<Script language = "JavaScript">

</Script>


3. You use ajax requests ..

Var username = 'sa ';

Var url = "login. action ";

Var pars = "username =" + username;

Var myAjax = new Ajax. Request (

Url ,{

Method: 'post', // Request method

Parameters: pars, // Parameter

OnComplete: showResponse // callback function

}

);



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.