Form Object
Forms on the page are represented in JavaScript via the form object, and can
be accessed in one of the 3 standard ways below:
document.yourformname //where yourformname is the name of
your form.
document.form.yourformname
document.forms["yourformname"]
Events
Events |
Description |
onReset |
Code is executed when the form is
reset (by clicking on "reset" button) |
onSubmit |
Code is executed when form is
submitted. |
Properties
Properties |
Description |
action |
Read/write string that reflects the
action attribute of the form. |
elements[] |
An array containing all of the
elements of the form. Use it to loop through form easily. |
encoding |
Read/write string that specifies how
the form data is encoded. |
length |
The number of elements in the form. |
method |
Read/write string that specifies how
the method the form is submitted. |
name |
The name of the form. |
target |
The name of the target frame or window
form is to be submitted to. |
Methods
Methods |
Description |
reset() |
Resets the form. |
submit() |
Submits a form.
Example(s). |
Examples
submit()
<a href="javascript:document.myform.submit()"><img src="submit.gif" /></a>