advertisement -- please support sponsors

forms:
automatically adjusting form data before submission

The behavior of form submit buttons can be programmed using the onClick event handler. Through this event handler, form data can be "pre-processed" just before it is submitted.

For example, suppose that a form's text field is used to submit the user's first name. Suppose also that we want the first names written in all capital letters. The following code shows how we can use the submit button's onClick event handler to accomplish this:

Enter first name and push GO!: <input type=text name="first_name" > <input type=submit value="GO!" onClick="form.first_name.value=form.first_name.value.toUpperCase();" >

Note, however, that the submit button's onClick event handler cannot be used to cancel the submit. To control whether or not a form is submitted, use the form's onSubmit event handler. See Netscape's JavaScript documention for more information on cancelling submit requests.

Charlton Rose
10/19/96