JavaScript Page Information interaction

Source: Internet
Author: User

This article describes how to implement Web page information interaction using JavaScript scripts. The main features and uses of the basic elements in the form are described. To achieve dynamic interaction, you must have more complex knowledge about form objects (form) and Frame objects (Frames).

First, Form basic knowledge

Form objects enable designers to interact with client users with different elements of a form, without having to first enter data before making a dynamic change to the behavior of a Web document.

1. What is a Form object

form: It forms the basic element of a Web page. Typically a Web page has a form or several forms, using the forms[] array to implement different forms of access.

There are three basic elements in forms[0], while Forms[1] has only two elements. www.82676666.com

The main function of a Form object is to have direct access to the form in an HTML document, which encapsulates the associated HTML code:

name = "Names of tables"

Target = "Submit window for specified information"

Action = "URL of the receiving form program"

method = Information Data transfer method (Get/post)

enctype = "Form encoding"

[]>

2. Methods of Form objects

The method of form object has only one--submit () method, the main function of this method is to implement the form information submission. If you submit a mytest form, the following format is used:

Document.mytest.submit ()

3. Properties of Form objects

The properties in the form object mainly include the following: Elements name Action target encoding method.

In addition to elements, several others reflect the state of the corresponding attribute in the identity in the form, which is usually a single form identifier, whereas elements is often an array of multiple form element values, for example:

Elements[0]. MYTABLE.ELEMENTS[1]

4. Accessing Form objects

Accessing form objects in JavaScript can be implemented in two ways: www.hrbfc120.com

(1) by accessing the form

In the properties of a Form object, you must first specify its form name, and then you can access the form by using the following identity: document. Mytable ().

(2) Accessing the form via an array

In addition to using the form name to access the form, you can also use the Form object array to visit the form object. However, it is important to note that the form object is provided by the browser environment, and the array subscript provided by the browser environment is 0 to N. Therefore, access to form objects can be implemented in the following format:

Document.forms[0]

DOCUMENT.FORMS[1]

DOCUMENT.FORMS[2] ...

5. Prerequisites for referencing forms

The condition that you want to refer to a form in JavaScript is that you must first create a form with an identity in the page, and then place the definition form part before the reference.

Ii. basic elements in a form

The basic elements in a form consist of buttons, radio buttons, check buttons, submit buttons, reset buttons, text boxes, and so on.

To access these basic elements in JavaScript, you must do so by using an array subscript or form element name that corresponds to a particular form element. Each element is referenced primarily by the attributes or methods of the element. The basic format of its reference is shown below:

Formname.elements[].methadname (form name. element name or array. method)

Formname.elemaent[].propertyname (form name. element name or array. properties)

The following are respectively described:

1. Text single row INPUT element

Function: Effective control over elements in the text ID.

Basic properties:

Name: Set the information names when submitting information. Corresponds to the name in the HTML document.

Value: The information that is used to set the value in the corresponding HTML document that appears in the window.

DefaultValue: Includes default values for text elements

Basic methods:

Blur (): Moves the current focus to the background.

Select (): Highlight text.

Main events:

Onfocus: This event occurs when text receives focus.

OnBlur: The event is generated when the element loses focus.

Onselect: When the text is highlighted, the file is generated.

OnChange: This file is generated when the value of the text element changes. Www.120hrb.com

Cases:...

...

2, textarea multi-row multi-column INPUT element

Function: Implementation controls the elements in the textarea.

Basic properties

Name: Set the information names when submitting information, corresponding to the textarea of the HTML document.

Value: The information that is used to set the value in the corresponding HTML document that appears in the window.

Default value: The defaults for the element.

Method:

Blur (): Loses the input focus

Select (): After highlighting the text

Event:

OnBlur: This event occurs when the input focus is lost

Onfocus: When the input gets focus, the file is generated

Onchange: This event occurs when a literal value is changed

Onselect: When the text is highlighted, the file is generated

3. Select element

Function: Implements control of the scrolling selection element.

Property:

Name: Set the information names for the submission, corresponding to name in the document select.

Length: Length in the corresponding document select

Options: Arrays that make up multiple options

Selectindex; the subscript indicates an option

Select in each of the options contains the following properties:

Text: The type of the option

Selected: Indicates whether the current option is selected

Index: Indicates the location of the current option

defaultselected: Default Options

Event:

OnBlur: The file is generated when the Select option loses focus.

Onfocas: The file is generated when Select gets the focus.

Onchange: This event occurs after the option State has changed. Www.hrbfkyy120.com

4. Button buttons

Function: Implements control of button buttons.

Property:

Name: Set the information names for the submission, corresponding to the button in the document.

Value: The information that is used to set the value in the corresponding HTML document that appears in the window.

Method:

Click () This method is similar to a pressed button.

Event:

OnClick The event occurs when the button is clicked.

Cases:

...

.....

5. CheckBox check box

Function: Enforces control over an element with a check box.

Property:

Name: Set the information names when submitting information.

Value: The information that is used to set the value in the corresponding HTML document that appears in the window.

Checked: This property indicates the state of the box true/false.

Defauitchecked: Default state

Method:

Click () This method causes an item of the box to be selected.

Event:

OnClick: This event is generated when the selection of the box is selected.

6. Radio Wireless button

Function: Implement a wireless button control with a single radio function.

Property:

Name: The information names when setting the submission, corresponding to the radio's name in the HTML document

Value: The information that is used to set the value in the corresponding HTML document that appears in the window, corresponding to the name of the radio in the HTML document.

Length: The number of buttons in the radio button.

Defalechecked: Default button.

Checked: Indicates whether the check is selected or not selected.

Index: The position of the selected button.

Method:

Chick (): Select a button.

Event:

OnClick: The event is generated when the button is clicked. Www.mlybyby.com

7, Hidden: Hide

Function: Implements control over an AREA element that has no display text and can enter characters.

Property:

Name: Sets the information names for the submission, corresponding to name in the hidden of the HTML document.

Value: The information that is used to set the value in the corresponding HTML document that appears in the window, corresponding to value in the HTML document hidden.

Defaleitvalue: Default Value

8. Password Password

Function: Implements control over elements that have password input.

Property:

Name: Sets the information names for the submission, corresponding to name in password in the HTML document.

Value: Used to set the information that appears in the window corresponding to the value in the HTML document, corresponding to the value in password in the HTML document.

Defaultvalu: Default Value

Method

Select (): Highlight the input password field.

Blur (): Causes this to lose passward input focus.

Focus (): Gets the password input focus.

9. Submit Submission Element

Function: Implements the control of a button with a submit function.

Property:

Name: Set the information names when submitting information, corresponding to the HTML document submit.

Value: The information that is used to set the value in the corresponding HTML document that appears in the window, corresponding to the value in the HTML document.

Method

Click () is equivalent to pressing the submit button. Www.mlyrx120.com

Event:

OnClick () generates the event when the button is pressed.

JavaScript Page Information interaction

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.