<FORM>...</FORM>
Description
Create a form inside a document. A form consists of one or more input-capable
fields. The form can include GUI-elements such as radio-buttons, checkboxes,
buttons and textfields.
Using a form you can send information to the Web-server which will invoke the
supplied program and pass the information to that program. So with forms you
can allow the user to pass data to the server. Forms can be used for things
such as order-entry, supplying search criteria or subscribing to a mailing
list.
The fields of a form are defined using the
INPUT,
SELECT and
TEXTAREA elements.
The FIELDSET element can group fields within
the form logically.
DTD
<!ELEMENT FORM - - (%block;|SCRIPT)+ -(FORM) -- interactive form -->
<!ATTLIST FORM
%attrs; -- %coreattrs, %i18n, %events --
action %URI; #REQUIRED -- server-side form handler --
method (GET|POST) GET -- HTTP method used to submit the form--
enctype %ContentType; "application/x-www-form-urlencoded"
onsubmit %Script; #IMPLIED -- the form was submitted --
onreset %Script; #IMPLIED -- the form was reset --
accept-charset %Charsets; #IMPLIED -- list of supported charsets --
>
from the
HTML 4.0 DTD,
"Copyright ©
W3C,
(MIT,
INRIA,
Keio).
All Rights Reserved."
Attributes
Core attributes:
class
id
style
title
Internationalization attributes:
dir
lang
Events:
onclick
ondblclick
onmousedown
onmouseup
onmouseover
onmousemove
onmouseout
onkeypress
onkeydown
onkeyup
ACCEPT
This attribute specifies a list of content types, separated by commas, that the
server that handles the form, accepts. A browser can use this information for
INPUT elements with type="file", to select which files may be uploaded.
ACCEPT-CHARSET
This attribute specifies a list of character encodings, that the server must be
able to process when the form is submitted. The values in the list may be
space- or comma-delimited.
The default value is "UNKNOWN", a reserved value. The browser handles this as
the same character encoding that is used for the page that contains the FORM.
ACTION
When the user submits the form the browser will use the value of this attribute
to know where to send the data. This can be the URL of a program that processes
the data, or an email address. For an email address use the format
mailto:joe@unknown.org
to send the data to joe@unknown.org.
The mailto: address is not supported by Microsoft's Internet Explorer.
ENCTYPE
Specifies the MIME type that will be used to encode the form's contents that
will be sent to the server. The default is
application/x-www-form-urlencoded
.
Netscape introduced the type multipart/form-data
which is used to implement <INPUT type="file">.
METHOD
This attribute determines which HTTP method will be used to pass the data to
the program. Which method you must use depends on the program that processes
the incoming data.
Value |
Description |
GET |
The data is appended to the URL of the program.
The result is that the data is not passed directly to the program but
made available in an environment variable called QUERY_STRING.
|
POST |
This sends the input information in a data body that is available on stdin
with the data length set in the environment variable CONTENT_LENGTH.
|
The default method is GET.
ONRESET
JavaScript code to execute when the user presses an input field with
type="reset".
ONSUBMIT
JavaScript code to execute when the user presses an input field with
type="submit".
TARGET
The TARGET attribute forces the load of that link into the targeted window.
The value supplied with the attribute must be the same as the name of the
window, and is case-sensitive. You can give a window a name with the
FRAME element. If a window with the supplied
target name does not exists then a new window will be created with that
name.
If you do not specify a target window the current window will be used, or the
target specified with the BASE element.
These names all begin with the underscore character. Any targeted window name
beginning with underscore which is not one of these names, will be ignored.
Value |
Description |
_blank |
This target will cause the link to always be loaded in a new blank window.
This window is not named.
|
_self |
This target causes the link to always load in the same window the anchor was
clicked in. This is useful for overriding a globally assigned BASE target.
|
_parent |
This target makes the link load in the immediate FRAMESET parent of this
document. This defaults to acting like _self if the document
has no parent.
|
_top |
This target makes the link load in the full body of the window. This
defaults to acting like _self if the document is already at the
top. It is useful for breaking out of an arbitrarily deep FRAME nesting.
|
Examples
 |
<FORM method="post" action="_URL_" onreset="alert('The form is reset')">
<TABLE>
<TR><TD>Name </TD><TD><INPUT type="text" name="name"></TD></TR>
<TR><TD>E-mail</TD><TD><INPUT type="text" name="email"></TD></TR>
<TR><TD colspan="2">How did you find these pages
<SELECT name="findout">
<OPTION>Newsgroup
<OPTION>Link on another page
<OPTION>Search engine
</SELECT></TD></TR>
<TR><TD colspan="2" align="center"><INPUT type="submit" value="Send values">
<INPUT type="reset" value="Reset form"></TD>
</TR>
</TABLE>
</FORM>
|
|
 |
|
|
 |
<FORM action="_URL_" enctype="multipart/form-data" onsubmit="alert('Submitting the form')">
Send this file: <INPUT name="userfile" type="file">
<INPUT type="submit" value="Send File">
</FORM>
|
|
 |
|
|
 |
Please put me on you christmas-card list :
<FORM action="mailto:schluter@knoware.nl">
Name <INPUT name="Name">, Email address <INPUT name="Email">
<INPUT type="submit">
</FORM>
|
|
 |
Please put me on you christmas-card list :
|