Categorized | JavaScript

Form methods and properties

                  JavaScript has a few built-in methods and properties for dealing with forms. Three of them are especially important:

                  You can submit a form by using the submit() method. To submit the first form on
the page, do

document.forms[0].submit()

                  Please note that when a form is submitted by JavaScript the onsubmit event handler
is never executed. To reset the form, do

document.forms[0].reset()

                   I assume, but have not tested, that the onreset event handler isn’t executed
either if you reset the form through JavaScript. Finally, you can change the ACTION of a form if you want to:

document.forms[0].action = ‘the_other_script.pl’;

                    This can come in very handily if a form has to be submitted to another script in some
cases.

Related posts:

  1. Accessing the form elements                  The form validation script needs to access the form in the HTML page to determine what values the user...
  2. Determining values              Of course, the most important thing is to find out what the user has filled in or checked in...

Leave a Reply

*

Page Rank

Skype Online Status

Call me! - Shashidhar Kumar: My status is Offline