Perhaps the biggest advance that the HTML 2.0 specification made over its predecessors was the inclusion of elements that allowed for users to input information. These elements are the Form elements. They provide for the inclusion of objects like text boxes, choice lists, etc., and have proved invaluable for recent HTML applications, particularly search engines, database query entry and the like.
It should be noted that while these HTML elements can be used to easily define the presentation of the form to the user, the real value behind any form is in what it does with the information that is entered. For a form to do anything more than send a straight text dump of the form data (including control characters) to an e-mail address, the form data will need to be passed to some kind of CGI script, or server based executable for processing. (CGI scripting is outside of the scope of this reference and ample reference material is available elsewhere for those interested).
The following elements are used to create forms :
<FORM>- A form within a document
<INPUT ...>- One input field
<OPTION>- One option within a Select element
<SELECT>- A selection from a finite set of options
<TEXTAREA ...>- A multi-line input field
<LABEL ...>- Active Control Labels
Each variable field is defined by an
OPTION element and must have a
NAME attribute to identify its value in the data returned when
the form is submitted.
A very simple form for eliciting user response (as shown below) would be :
<H1 ALIGN="center">Comment Form</H1>
<FORM METHOD="POST" ACTION="http://www.htmlib.com/formscript.cgi">
Your name: <INPUT NAME="name" size="20">
Your e-mail address: <INPUT NAME="email" size="20">
<P>I think the HTML Reference is :
<OPTION SELECTED>My response would be "indecent" under the CDA Act.
<P>If you have any further comments, please enter them here:<BR>
<TEXTAREA NAME="Comments" ROWS="10" COLS="40">
<P><INPUT TYPE=SUBMIT> <INPUT TYPE=RESET>
Different platforms will have different native systems for navigating within
the input fields of a form. (e.g. Windows users can use the Tab key to move
from one field to the next through the order that the fields appear within
the form). Different browsers may also display different text on any buttons
included in the form. For example, Netscape defaults to displaying
'"Submit Query" for a button specified by
TYPE=SUBMIT>, while the Internet Explorer and Mosaic
display just "Submit" on such a button.
HTTP File Upload
It is possible to write forms that ask for files as input, rather than data input by input boxes and other simple elements such as checkboxes and radio buttons.
An example of such a form would be:
<FORM ENCTYPE="multipart/form-data" ACTION="_URL_" METHOD=POST>
Send this file: <INPUT NAME="userfile" TYPE="file">
<INPUT TYPE="submit" VALUE="Send File">
NOTE : This method of file upload is
Netscape specific and is essentially adoption of another
IETF Internet Draft by the Netscape authors. The Internet Draft in question,
"Form based file upload in HTML", details adding the
TYPE attribute of the
INPUT element, allowing
ACCEPT attribute for the
INPUT element (which
would be a list of MIME types - essentially detailing what files are allowed
to be uploaded as the contents of the form) and allowing the
ENCTYPE of a form to be "multipart/form-data". This MIME type
essentially wraps the form data (including that presented in any other input
fields) as a data stream, with discrete boundaries between the information
sections. For a more detailed description, readers should check the HTTP
file upload specification.
The display method is largely at the discretion of the browsers that support this method. Netscape (Windows versions) display a "Browse" button beside the input box which brings up the standard open/save dialog box, allowing the choice of any local file for upload.
© 1995-1998, Stephen Le Hunte
|file: /Techref/language/html/ib/Forms/ov.htm, 6KB, , updated: 2020/2/19 18:37, local time: 2022/9/24 08:44,
|©2022 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?|
<A HREF="http://www.sxlist.com/techref/language/html/ib/Forms/ov.htm"> Forms overview</A>
|Did you find what you needed?|
Welcome to sxlist.com!
& kind contributors
just like you!
Please don't rip/copy
Copies of the site on CD
are available at minimal cost.
Welcome to www.sxlist.com!