The Form element is used to delimit a data input form. There can be several forms in a single document, but the Form element can not be nested. (I.e. a form can't contain another form)
<FORM ACTION="_URL_" METHOD="GET|POST" ENCTYPE="MIME type">
. . .
The ACTION attribute is a URL specifying the location to which the contents of the form data fields are submitted to elicit a response. As mentioned before, this could be simply a direction to an e-mail address, but generally, would be used to point towards some kind of server based CGI script/application that handles the forwarding of form data. If the
ACTION attribute is missing, the URL of the document itself is assumed. The way data is submitted varies with the access protocol of the URL to which the form data is sent and with the values of the METHOD and ENCTYPE attributes.
METHOD attribute specifies a method of accessing the URL specified in the
ACTION attribute and will be either GET or POST. The
GET method is ideal for form submission where the use of the form data does not require external processing. For example, with database searches, there is no lasting effect caused by the query of the form (that is, the query runs its search through the database and reports the results). However, where the form is used to provide information for example, that updates a database, then the
POST method should be used, with the
ACTION attribute pointing to a CGI script that executes the form data processing.
ENCTYPE specifies the media type used to encode the form data. The default
ENCTYPE is the MIME type 'application/x-www-form-urlencoded'
<FORM> element can also accept the TARGET attribute (as in
<A> elements), to specify what window is used for any form feedback. It can take the following values :
<FRAME>element, or by using the
window.openscripting method. If a
window_nameis used which does not correlate to a previously defined window, then a new window is created and
NAMEd according the the window name used in the
TARGETattribute. This new window can then be referenced using its new name.
<FRAMESET>element definitions that control the form's current window.
TARGET="window_name"where the window_name used is not a previously defined window. NOTE : Unlike using the
window_nameusing a previously undefined window name, using
_blankwill not name the new window for future use.
<FORM> can also take the NAME attribute, which can be used to set the name of the element for scripting purposes.
The Internet Explorer 4.0 (and above) specific
TITLE attribute is used for informational purposes. If present, the value of the
TITLE attribute is presented as a ToolTip when the users mouse hovers over the
LANG attribute can be used to specify what language the
<FORM> element is using. It accepts any valid ISO standard language abbreviation (for example
"en" for English,
"de" for German etc.) For more details, see the Document Localisation section for more details.
LANGUAGE attribute can be used to expressly specify which scripting language Internet Explorer 4.0 uses to interpret any scripting information used in the
<FORM> element. It can accept values of
LANGUAGE attribute is set.
CLASS="Style Sheet class name"
CLASS attribute is used to specify the
<FORM> element as using a particular style sheet class. See the Style Sheets topic for details.
STYLE="In line style setting"
As well as using previously defined style sheet settings, the
<FORM> element can have in-line stylings attached to it. See the Style Sheets topic for details.
ID="Unique element identifier"
ID attribute can be used to either reference a unique style sheet identifier, or to provide a unique name for the
<FORM> element for scripting purposes. Any
<FORM> element with an
ID attribute can be directly manipulated in script by referencing its
ID attribute, rather than working through the All collection to determine the element. See the Scripting introduction topic for more information.
<FORM> element in a document is an object that can be manipulated through scripting. Both Netscape and Internet Explorer support scripting of the
<FORM> object - Netscape supporting it through the Forms collectionforms array, but Internet Explorer's Dynamic HTML support is more varied.
<FORM...> element/object supports all of the standard Dynamic HTML properties (i.e. className, document, id, innerHTML, innerText, isTextEdit, lang, language, offsetHeight, offsetLeft, offsetParent, offsetTop, offsetWidth, outerHTML, outerText, parentElement, parentTextEdit, sourceIndex, style, tagName and title). Details of these can be found in the standard Dynamic HTML properties topics.
<FORM> object also supports the following properties:
action, encoding, method, name and target, all of which directly reflect (or set) their respective attribute values (with the
encoding property reflecting the
<FORM...> element/object supports all of the standard Dynamic HTML methods (i.e. click, contains, getAttribute, insertAdjacentHTML, insertAdjacentText, removeAttribute, scrollIntoView and setAttribute). Details of these can be found in the standard Dynamic HTML Methods topics.
<FORM> element also supports the submit and reset methods, which submit, or reset the form respectively.
<FORM...> element/object supports all of the standard Dynamic HTML events (i.e. onclick, ondblclick, ondragstart, onfilterchange, onhelp, onkeydown, onkeypress, onkeyup, onmousedown, onmousemove, onmouseout, onmouseover, onmouseup and onselectstart). Details of these can be found in the standard Dynamic HTML events topics.
onreset and onsubmit are also supported events of the
<FORM> element, firing when the form is reset, or submitted respectively.