JavaScript: The Definitive Guide, Sixth Editio javaScript权威指南(第6版) pdf 文字版-文字版, javascript电子书, 和javascript 有关的电子书:

15.9.2 Form and Element Properties

15.9.2 Form and Element Properties


The elements[]array described above is the most interesting property of a Form object. The remaining properties of the Form object are of less importance. The action, encoding, method, and target properties correspond directly to the action, encoding, method, and targetattributes of theelement. These properties and attributes are all used to control how form data is submitted to the web server and where the results are displayed. Client-side JavaScript can set the value of these properties, but they are only useful when the form is actually submitted to a server-side program.

In the days before JavaScript, a form was submitted with a special-purpose Submit button, and form elements had their values reset with a special-purpose Reset button.

15.9 HTML Forms | 399

The JavaScript Form object supports two methods, submit() and reset(), that serve the same purpose. Invoking the submit() method of a Form submits the form, and invoking reset() resets the form elements.

All (or most) form elements have the following properties in common. Some elements have other special-purpose properties that are described later when various types of form elements are considered individually:

type

A read-only string that identifies the type of the form element. For form elements that are defined by antag, this is simply the value of the type attribute. Other form elements (such asand) define a type property so that they can easily be identified by the same test that distinguishes betweenelements. The second column of Table 15-1 lists the value of this property for each form element.

form

A read-only reference to the Form object in which the element is contained, or null if the element is not contained within aelement. name A read-only string specified by the HTML name attribute. value

A read/write string that specifies the “value” contained or represented by the form element. This is the string that is sent to the web server when the form is submitted, and it is only sometimes of interest to JavaScript programs. For Text and Textarea elements, this property contains the text that the user entered. For button elements created with antag (but not those created with atag) this property specifies the text displayed within the button. For radio and checkbox elements, however, the value property is not edited or displayed to the user in any way. It is simply a string set by the HTML value attribute. It is intended for use in form submission, but it can also be a useful way to associate extra data with a form element. The value property is discussed further in the sections on the different categories of form elements, later in this chapter.

欢迎转载,转载请注明来自一手册:http://yishouce.com/book/1/31435.html
友情链接It题库(ittiku.com)| 版权归yishouce.com所有| 友链等可联系 admin#yishouce.com|粤ICP备16001685号-1