|
To access the contents, click the chapter and section titles.
Platinum Edition Using HTML 4, XML, and Java 1.2
anchor objects are also referenced using an object arraythe anchors array. The only property of this object array, however, is the length property, which returns the number of elements in the array. The form ObjectThe HTML form object is the primary way for Web pages to solicit different types of input from the user. JavaScript will often work along with HTML forms to perform its functions. The object model for HTML forms includes a wide variety of properties, methods, and events. If you use these with each form, JavaScript can manipulate and access those forms. form Object PropertiesTables 19.4, 19.5, and 19.6 show some of the properties, methods, and events attached to HTML form objects. These can be used in JavaScriptsthe properties and methods can be used to access or manipulate information and to perform certain functions, and the events can be used to trigger JavaScript functions related to the form itself. If a form is named Form1, for instance, the method document.Form1.submit() can be called in JavaScript to submit the form. On the other hand, if the Submit button calls a function in response to an onSubmit event, the submission of the form can be disabled if the function returns a false value. This is a good way to perform form validation within the Web browser and to allow submission of the form only if all fields are validated. Note that the HTML form elements that can be included within the form, <INPUT>, <RADIO>, <CHECKBOX>, and other form tags, are also represented as objects and can be referenced by JavaScript. These form element objects are also properties of their parent formthey are discussed in the next section.
Using Objects to Manipulate Form ElementsA good place to use JavaScript is in forms; this is so because you can write scripts that process, check, and perform calculations with the data the user enters. JavaScript provides a useful set of properties and methods for text <INPUT> elements and buttons and the other form elements. You use <INPUT> elements in a form to enable the user to enter text data; JavaScript provides properties to get the objects that hold the elements contents as well as methods for doing something when the user moves into or out of a field. Table 19.7 shows some of the properties, methods, and events defined for <INPUT> form element objects.
|
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement. |