|
|
Q1342 Is there a way to programmatically click a submit button and ensure that the onClick event is fired?
irt.org | Knowledge Base | JavaScript | Form | Q1342 [ previous next ] Q1342 Is there a way to programmatically click a submit button and ensure that the onClick event is fired?Netscape will not execute an "noWhatever" event handler if one executes a "whatever()" method via a script. Although this limitation was true, it seems that it later versions of Netscape Navigator (e.g. 4.6) this is no longer true. So for example document.myForm.submit() does not trigger the onSubmit() event handler, but you can handle that by invoking the form buttons click(0 method:
If you have the following form which invokes the validate() function to validate the form prior to submission:
Then it can be adapted so that a form button can be used to first ensure the form is valid and then submit the form:
And adapted further still to allow the same thing with a link:
The following shows an alternative approach to using the click() method, by invoking the onclick() method:
Feedback on 'Q1342 Is there a way to programmatically click a submit button and ensure that the onClick event is fired?' |
-- div -->
|