Element ObjectNameElement Object---a form elementAvailabilityNavigator 2.0, Internet Explorer 3.0; enhanced in Navigator 3.0 Synopsis
form.elements[i] form.name Properties
Event Handlers
DescriptionForm elements are stored in the elements[] array of the Form object. The contents of this array are Element objects, which represent the individual buttons, input fields and other controls that appear within the form. Strictly speaking, all elements within a form are represented by Element objects. It is often more convenient, however, to consider these object to have the type of the form element they represent. Thus, in this book we often refer to Button objects, Text objects, Select objects, and so on. This reference page describes the general behavior of form elements. Specific behaviors for form elements are described on their own pages. The Element object defines quite a few properties, methods, and event handlers, but not all of them are functional for each type of form element. For example, the Button object triggers the onclick() event handler, but not the onchange() handler, while the Text object triggers onchange() but not onclick(). The following figure shows all of the form elements and the properties associated with them. In general, there are two broad categories of form elements. The first is the buttons: Button, Checkbox, Radio, Reset, and Submit. These elements have an onclick() event handler, but not an onchange() handler. Similarly, they respond to the click() method but not the select() method. The second category are those elements that display text: Text, Textarea, Password and FileUpload. These elements have an onchange() event handler rather than an onclick() handler, and respond to the select() method but not the click() method. The Select and Hidden elements are special, and do not fall into either of the above two categories. The Select element uses several properties of the Element object not used by any other objects, and, surprisingly does not use the value property--values for this object are supplied by the Option objects it contains. Finally, the Hidden element has no on-screen representation, so it does not have any event handlers nor does it respond to any methods. BugsUnfortunately, the behavior of form elements varies on different platforms, at least in Navigator 2.0 and Navigator 3.0 (Internet Explorer 3.0 only runs on one platform). On Unix platforms, which run the X11 window system, only the text-entry form elements participate in keyboard navigation, and so the button elements and the Select element do not respond to the blur() and focus() methods nor do they invoke the onblur() and onfocus() event handler. Also, on Unix systems, the Text element is the only one that responds to the select() method. On Windows platforms, on the other hand, all form elements are fully "wired in," and they all respond as noted in the table. |
|