JavaScript script implements web page information interaction

Source: Internet
Author: User

To implement dynamic interaction, you must have more sophisticated knowledge about form objects (form) and Frame objects (Frames).

Basic knowledge of forms

Form objects enable designers to interact with client users with different elements of a form, without having to enter data first before they can dynamically alter the behavior of Web documents.

1. What is a Form object

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

<form Name=Form1>
<INPUT type=text...>
<Input type=text...>
<Inpup byne=text...>
</form>
<form Name=Form2>
<INPUT type=text...>
<Input type=text...>
</form>

There are three basic elements in forms[0], and there are only two elements in forms[1].

The main function of a Form object is the ability to directly access a form in an HTML document, which encapsulates the relevant HTML code:

<Form
Name ="表的名称"
Target ="指定信息的提交窗口"
action ="接收窗体程序对应的URL"
Method =信息数据传送方式(get/post)
enctype ="窗体编码方式"
[onsubmit ="JavaScript代码"]>
</Form>

2, the Form object method

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

Document.mytest.submit ()

3, the properties of the Form object

Properties in form objects mainly include the following: Elements name Action target encoding method.

In addition to elements, several others reflect the state of the corresponding property in the identity in the form, which is usually an individual form identity, while elements is often an array of multiple form element values, for example:

Elements[0]. MYTABLE.ELEMENTS[1]

4. Accessing Form objects

Accessing a Form object in JavaScript can be implemented in two different ways:

(1) by accessing the form

You must first specify its form name in the properties of the Form object, and then you can access the form through the following identities: document. Mytable ().

(2) Access to the form through the 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, you can implement access to form objects in the following formats:

Document.forms[0]

DOCUMENT.FORMS[1]

DOCUMENT.FORMS[2] ...

5. Prerequisites for referencing forms

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

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.