Web page information interaction using JavaScript scripts _ basic knowledge

Source: Internet
Author: User
To achieve dynamic interaction between Web page information through JavaScript scripts, you must have more complex knowledge about Form and Frames.

I. Basic form knowledge
The form object allows the designer to interact with client users using different elements in the form, without having to input data before, the Web document behavior can be dynamically changed.

1. what is a form object?
Form: it forms the basic elements of a web page. Generally, a Web page has one or several Forms, and Forms [] arrays are used to access different Forms.


There are three basic elements in Forms [0], and Forms [1] only has two elements.
The main function of a form object is to directly access the form in the HTML document. it encapsulates the relevant HTML code:

 

2. method of form object
There is only one -- submit () method for the form object method. The main function of this method is to submit the form information. If the Mytest form is submitted, the following format is used:
Document. mytest. submit ()
 
3. form object attributes
The attributes in the form object mainly include: elements name action target encoding method.
Except Elements, other elements all reflect the status of corresponding attributes in the form identity, which is usually a single form identity. Elements is often an array of multiple form element values, for example:
Elements [0]. Mytable. elements [1]
 
4. access the form object
You can use either of the following methods to access a form object in JavaScript:
(1) access the form
In the form object attributes, you must specify the form name, and then you can access the form using the following identity: document. Mytable ().
(2) access the form through arrays
In addition to using the form name to access the form, you can also use the form object array to access the form object. Note that because the form object is provided by the browser environment, the array subscript provided by the browser environment is from 0 to n. Therefore, you can access a form object in the following format:
Document. forms [0]
Document. forms [1]
Document. forms [2]...
 
5. prerequisites for referencing a form
In JavaScript, you must first create a form with an identifier on the page and place the part of the definition form before the reference.
 
II. basic elements in the form
The basic elements in the form are composed of buttons, radio buttons, check buttons, submit buttons, reset buttons, and text boxes.
To access these basic elements in JavaScript, you must use the array subscript or form element name corresponding to a specific form element. Each element is referenced by its attributes or methods. For the basic format of its reference, see:
FormName. elements []. methadName (Form name. element name or array. method)
FormName. elemaent []. propertyName (Form name. element name or array. attribute)
 
The following sections describe:
 
1. single-column input elements in a single Text row
Function: effectively controls the elements in the Text mark.
Basic attributes:
Name: specifies the Name of the information submitted. Corresponds to the Name in the HTML document.
Value: used to set the Value information corresponding to the HTML document in the window.
Defaultvalue: includes the default value of the Text element.
Basic method:
Blur (): Move the current focus to the background.
Select (): Highlight text.
Main events:
OnFocus: This event is generated when Text gets the focus.
OnBlur: This event is generated when the element loses focus.
Onselect: This file is generated when the text is highlighted.
Onchange: This file is generated when the Text element value changes.
Example :...

...

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.