25.132. Form: a <form> in an HTML documentDOM Level 2 HTML: Node Element HTMLElement Form25.132.1. Properties
In addition to these properties, Form also defines the properties in the following table, which correspond directly to HTML attributes:
25.132.2. Methods
25.132.3. Event Handlers
25.132.4. HTML SyntaxA Form object is created with a standard HTML <form> tag. The form contains input elements created with <input>, <select>, <textarea>, and other tags: <form [ name="form_name" ] // Used to name the form in JavaScript [ target="window_name" ] // The name of the window for responses [ action="url" ] // The URL to which the form is submitted [ method=("get"|"post") ] // The method of form submission [ enctype="encoding" ] // How the form data is encoded [ onreset="handler" ] // A handler invoked when form is reset [ onsubmit="handler" ] // A handler invoked when form is submitted > // Form text and input elements go here </form> 25.132.5. DescriptionThe Form object represents a <form> element in an HTML document. The elements property is an HTMLCollection that provides convenient access to all elements of the form. The submit( ) and reset( ) methods allow a form to be submitted or reset under program control. Each form in a document is represented as an element of the Document.forms[] array. Named forms are also represented by the form_name property of their document, where form_name is the name specified by the name attribute of the <form> tag. The elements of a form (buttons, input fields, checkboxes, and so on) are collected in the Form.elements[] array. Named elements, like named forms, can also be referenced directly by name: the element name is used as a property name of the Form object. Thus, to refer to an Input element named phone within a form named questionnaire, you might use the JavaScript expression: document.questionnaire.phone 25.132.6. See AlsoInput, Select, Textarea; Chapter 18 |