Creating JSON objects in JavaScript--routine parsing

Source: Internet
Author: User

Iamlaosong

To use a program to grab data from a Web page, you need to familiarize yourself with the HTML and JavaScript languages, and here's a routine that creates a JSON object in JavaScript, learns and grasps its content, makes a note of the routine here, records what I know, and prepares it for future verification.

The program is simple and divided into three parts:

1. display the title with large characters;

2, <p> part: Show the structure of a piece of information, but no content, the content is added later;

3, <scrip> part:JavaScript program, first defines a JSON structure of the variable jsonobject, and then, with the contents of the variable to fill in the <p> section, the positioning method is defined by the ID, Here is a detailed explanation:

Statement document.getElementById ("Jname"). Innerhtml=jsonobject.name is to find the element with ID jname, replace the content with Jsonobject.name, the content of this variable is Bill Gates, which is:

Change <span id= "Jname" ></span> to <span id= "Jname" >bill gates</span>

When we use the program to capture data from the Web page, we often need to fill in the form, but also in this way to modify the content of the page, finally submitted, to get what we need, for example, the following statement is to fill in the email number and submit the query:

WebBrowser1.Document.GetElementById ("Mailnum"). InnerText = "1126381490399"
WebBrowser1.Document.Forms ("Mailtracksnglform"). Submit

You can also use the following notation:

WebBrowser1.document.Forms ("Mailtracksnglform"). All ("Mailnum"). Value ="1126381490399"

For example, after completing the user name and password, submit:

WebBrowser 1.document.forms (0). All ("name"). Value = "AHSD08"
WebBrowser 1.document.forms (0). All ("password"). Value = "song0829"
WebBrowser 1.document.forms (0). Submit

corresponding to the elements of the page or object positioning, you can use the ID name, you can also use the serial number, such as the above example of Forms (0).

The following is the example code for the analysis above:


The following results are performed:

Create a JSON object in Javascript

Author: iamlaosong
Name: Bill Gates
Age:
Address: Fifth Avenue New York 666
Phone: 555 1234567


Creating JSON objects in JavaScript--routine parsing

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.