Form Object
Forms are used to prompt users for input. We may use form elements such as
text fields, radio buttons, checkboxes and selection lists. The input data is
normally posted to a server for processing.
The Form object's collections, properties, methods, and events are
described below:
N: Netscape (including Mozilla when N6 or higher), IE: Internet Explorer, W3C:
World Wide Web Consortium (Internet Standard)
Collections
Collection |
Description |
N |
IE |
W3C |
elements[] |
Returns an array containing each element in the form |
2 |
3 |
Yes |
Properties
Syntax: object.property_name
Property |
Description |
N |
IE |
W3C |
acceptCharset |
Sets or returns a list of character encodings for form data
that must be accepted by the server processing the form |
|
3 |
Yes |
action |
Sets or returns the URL of where the input data will be
submitted |
2 |
3 |
Yes |
encoding |
Sets or returns the MIME encoding for the form |
2 |
3 |
No |
enctype |
Sets or returns the MIME encoding for the form |
6 |
5 |
Yes |
id |
Sets or returns the id of the form (In IE 4 this
property is read-only) |
|
4 |
No |
length |
Returns the number of elements in a form |
2 |
3 |
Yes |
method |
Sets or returns how form data is submitted to the server ("get" or
"post") |
2 |
3 |
Yes |
name |
Sets or returns the name of the form |
2 |
3 |
Yes |
tabIndex |
Sets or returns the index that defines the tab order for
the form |
|
5 |
No |
target |
Sets or returns the target window or frame that responses are sent
to after submission of a form |
2 |
3 |
Yes |
Methods
Syntax: object.method_name()
Method |
Description |
N |
IE |
W3C |
reset() |
Resets the default values of all elements in the form (same as clicking
the Reset button) |
3 |
4 |
Yes |
submit() |
Submits the form (same as clicking the Submit button) |
2 |
3 |
Yes |
Events
Syntax: object.event_name="someJavaScriptCode"
Event |
Description |
N |
IE |
W3C |
onReset |
Executes some code when a Reset event occurs |
3 |
4 |
|
onSubmit |
Executes some code when a Submit event occurs |
2 |
3 |
|
|