please dont rip this site

JavaScript: The Definitive Guide

Previous Chapter 21
JavaScript Reference
Next
 

Form Object

Name

Form Object---an HTML input form

Availability

Navigator 2.0, Internet Explorer 3.0

Synopsis

document.form_name
document.forms[form_number]
document.forms.length

Properties

action

A read/write string specifying the URL to which the form is to be submitted. Initially specified by the ACTION attribute.

elements[]

An array of input elements that appear in the form. Each element is a Button, Checkbox, Hidden, Password, Radio, Reset, Select, Submit, Text, or Textarea object.

elements.length

The number of items in the elements[] array.

encoding

A read/write string that specifies the encoding method used for form data. Initially specified by the ENCTYPE attribute. The default encoding of "application/x-www-form-urlencoded" is almost always appropriate.

method

A read/write string that specifies the technique for submitting the form. It should have the value "get" or "post". Initially specified by the METHOD attribute.

target

A read/write string that specifies the name of the frame or window in which the results of submitting a form should be displayed. Initially specified by the TARGET attribute. The special names "_top", "_parent", "_self", and "_blank" are also supported for the target property and the TARGET attribute.

Methods

reset()

Reset each of the input elements of the form to their default values.

submit()

Submit the form.

Event Handlers

onreset()

An event handler invoked just before the elements of the form are reset. Specified by the onReset attribute.

onsubmit()

An event handler that is invoked just before the form is submitted. Specified by the onSubmit attribute. This event handler allows form entries to be validated before being submitted.

HTML Syntax

A Form object is created with a standard HTML <FORM> tag. JavaScript adds the optional onReset and onSubmit event-handler attributes to this tag. The form contains any input elements created with the <INPUT> tag between <FORM> and </FORM>.

<FORM
    [ NAME="form_name" ]  used to name the form in JavaScript
    [ TARGET="window_name" ]  the name of the window for responses
    [ ACTION="url" ]  the URL to which the form is submitted
    [ METHOD=(GET|POST) ]   the method of form submission
    [ ENCTYPE="encoding" ]    how the form data is encoded
    [ onReset="handler" ] a handler invoked when form is reset
    [ onSubmit="handler" ]    a handler invoked when form is submitted
>
    form text and <INPUT> tags go here
</FORM>

Description

The Form object represents an HTML <FORM> in a document. Each form in a document is represented as an element of the Document.forms[] array. Named forms are also represented by the form_name property of their document, where form_name is the name specified in the NAME attribute of the <FORM> tag.

The elements of a form (buttons, input fields, check boxes, and so on) are collected in the Form.elements[] array. Named elements, like named forms, can also be referenced directly by name--the element name is used as a property name of the Form object. Thus, to refer to a Text object element named "phone" within a form named "questionnaire," you might use the JavaScript expression:

document.questionnaire.phone

See the descriptions of the Form properties and methods for more information about this object.

See Also

"Button", "Checkbox", "Element", "FileUpload", "Hidden", "Password", "Radio", "Reset", "Select", "Submit", "Text", "Textarea"


Previous Home Next
focus() Book Index Form.action

HTML: The Definitive Guide CGI Programming JavaScript: The Definitive Guide Programming Perl WebMaster in a Nutshell

file: /Techref/language/JAVA/SCRIPT/definitive/refp_131.htm, 9KB, , updated: 2019/10/14 15:00, local time: 2024/12/23 12:39,
TOP NEW HELP FIND: 
18.191.200.151:LOG IN

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://massmind.org/techref/language/JAVA/SCRIPT/definitive/refp_131.htm"> [Chapter 21] Reference: Form</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

 

Welcome to massmind.org!

 

Welcome to massmind.org!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .