543Chapter 23 .The Form and Related Objects A (Web site layout)

543Chapter 23 .The Form and Related Objects A common practice, especially with a long form, is to provide a button that enables the user to return all the form elements to their default settings. The standard Reset button (a separate object type described in Chapter 24) does that task just fine. But if you want to clear the form using script control, you must do so by invoking the reset()method for the form. More than likely, such a call is initiated from outside the form, perhaps from a function or graphical button. In such cases, make sure that the reference to the reset()method includes the complete reference to the form you want to reset even if the page only has one form defined for it. On the CD-ROM Example (with Listing 23-3) on the CD-ROM Related Items: onReset event handler; reset object. submit() Returns: Nothing. NN2 NN3 NN4 NN6 IE3/J1 IE3/J2 IE4 IE5 IE5.5 Compatibility . . . The most common way to send a form s data to a server s CGI program for processing is to have a user click a Submit button. The standard HTML Submit button is designed to send data from all named elements of a form according to the specifications listed in the

definition s attributes. But if you want to submit a form s data to a server automatically for a user, or want to use a graphical button for submission, you can accomplish the submission with the form.submit() method. Invoking this method is almost the same as a user clicking a form s Submit button (except that the onSubmitevent handler is not triggered). Therefore, you may have an image on your page that is a graphical submission button. If that image is surrounded by a link object, you can capture a mouse click on that image and trigger a function whose content includes a call to a form s submit() method (see Listing 23-3). In a multiple-form HTML document, however, you must reference the proper form either by name or according to its position in a document.forms array. Always make sure that the reference you specify in your script points to the desired form before you submit any data to a server. As a security and privacy precaution for people visiting your site, JavaScript ignores all submit() methods whose associated form actions are set to a mailto: URL. Many Web page designers would love to have secret e-mail addresses captured from visitors. Because such a capture can be considered an invasion of privacy, the power has been disabled since Navigator 2.02. You can, however, still use an explicit Submit button object to mail a form to you from browsers. (See the section, E-mailing forms earlier in this chapter.) FORM.submit()
Check Tomcat Web Hosting services for best quality webspace to host your web application.

Leave a Reply