• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 12. Handling Events > Handling a Form Event

12.6. Handling a Form Event

As discussed in Chapter 11, “The Document Objects: Forms, Images, and Links,” the document object has a forms property. It contains an array of all the forms that have been defined in the document. Each element of the array is a form object and the number in the index of the array represents the order in which the form appeared on the page. The first form would be document.forms[0]. Each form contains elements, also represented as an array. The elements represent the input types of the form, such as a checkbox, radio button, or text field. By naming each of the forms and its respective elements, it is much easier to work with them in JavaScript. (See Chapter 11 for a complete discussion of the forms[] array.) There are a number of events associated with the form's elements. Many of them were also covered in Chapter 11. They are listed in Table 12.6.

Table 12.6. Event handlers for the form's elements.
ObjectEvent Handler
buttononClick, onBlur, onFocus
checkboxonClick, onBlur, onFocus
FileUpLoadonClick, onBlur, onFocus
hiddennone
passwordonBlur, onFocus, onSelect
radioonClick, onBlur, onFocus
resetonReset
selectonFocus, onBlur, onChange
submitonSubmit
textonClick, onBlur, onFocus, onChange
textareaonClick, onBlur, onFocus, onChange



PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint