Home > Web Front-end > JS Tutorial > JavaScript tutorial script to implement page information interaction

JavaScript tutorial script to implement page information interaction

黄舟
Release: 2016-12-22 15:35:44
Original
1135 people have browsed it

To achieve dynamic interaction, you must master more complex knowledge about the form object (Form).

Basic knowledge of forms

The form object allows designers to use different elements in the form to interact with client users, without having to enter data first, to dynamically change the behavior of the Web document.

1. What is a form object?

Forms constitute the basic elements of Web pages. Usually a Web page has one form or several forms, and the Forms[] array is used to achieve access to different forms.

2. Methods of the form object

The form object has only one method--submit() method. The main function of this method is to submit the form information. If you submit the Mytest form, use the following format: document.mytest.submit().

3. Properties of the form object

The properties in the form object mainly include the following: elements name action target encodingmethod.

Except Elements, the others all reflect the status of the corresponding properties in the logo in the form. This It is usually a single form identifier; elements is often an array of multiple form element values, for example: elements[0].Mytable.elements[1].

4. Access the form object

Accessing the form object in JavaScript can be achieved by two methods:

a. By accessing the form

In the properties of the form object, you must first specify its form name, and then The form can be accessed through the following identifiers: document.Mytable().

b. Access the form through array

In addition to using the form name to access the form, you can also use the form object array to access the form object. But one thing to note is that the form object is provided by the browser environment, and the array subscripts provided by the browser environment range from 0 to n. Therefore, the form object can be accessed through the following format:

document.forms[0]

document.forms[1]

document.forms[2]...

5. Prerequisites for referencing forms

The conditions for referencing a form in JavaScript are: the form must be created with the identifier in the page first, and the form definition part must be placed before the reference.


Basic elements in forms

Basic elements in forms consist of buttons, radio buttons, check buttons, submit buttons, reset buttons, text boxes, etc.

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 mainly referenced through the attributes or methods of the element. The basic format of its reference is as follows:

formName.elements[].methadName (form name. element name or array. method)

formName.elemaent[].propertyName (form name. element name or array. property)

The above is the JavaScript tutorial script to implement page information interaction. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template