Share this Page URL
Help

Hour 14. Getting Data with Forms > Using the form Object with JavaScript - Pg. 124

Getting Data with Forms 124 The <form> tag is followed by one or more form elements. These are the data fields in the form, such as text fields, buttons, and check boxes. In the next section, you'll learn how JavaScript assigns objects to each of the form elements. Using the form Object with JavaScript Each form in your HTML page is represented in JavaScript by a form object, which has the same name as the NAME attribute in the <form> tag you used to define it. Alternately, you can use the forms array to refer to forms. This array includes an item for each form element, indexed starting with 0. For example, if the first form in a document has the name form1, you can refer to it in one of two ways: document.form1 document.forms[0] The form Object's Properties Along with the elements, each form object also has a list of properties, most of which are defined by the corresponding <form> tag. You can also set these from within JavaScript. They include the following: · action is the form's ACTION attribute, or the program to which the form data will be submitted. · encoding is the MIME type of the form, specified with the ENCTYPE attribute. In most cases, this is not needed.