Introduction


Forms, which enables visitors to a web site to give input, are used for various purposes. For instance, forms can be used for order processing on retail site or they can be set up to get customer feedback by email.
The form element contains several other elements called controls.When the form is completed and submited, the information in its active controls is passed to a program that takes whatever action the form has been designed to perform.

Each element in the form has both name and value, thus the data that's passed for processing is in the form of name/value pairs.Often, the processing of data is done with CGI program.
These programs are usually written in Perl, but can be any language that can run on the server, such as Java and C.Another method of from data handling is to pass the information to JavaScript or VBScript.

The Form Element Input Element Button Element
Select And Option Element The Textarea Element The Lable Element

The Form Element

The form element has two main attributes : action and method, The action attribute is required and takes a URL as its argument. Additional attributes define the encoding type and event handlers.
Syntax:

<Form action=URL [method=get|post]
  [enctype = "application/x - WWW - form-urlencoded"]
[onsubmit = script]> ...form elements... </form>

The method attribute can have either GET or POST as its values ; Get is default value choice. Get submits the name/value pair to specified URL. POST on the other hand sends them as separate section following HTTP header.

The Input Element

The Input element is most critial to use forms. It's entirely possible to build an entire form using no other elements due to the variety of attributes avaliable.
Syntax

<Input [type=text|password|checkbox|radio|submit|reset|image|button|
 hidden|file][name=controlname][value=controlvalue][cheked][src=URL]
 [align=""]>

The Form Element Input Element Button Element
Select And Option Element The Textarea Element The Lable Element

The Button Element

The Button element was once limited to two options-sending or clearing the form.With HTML 4.0, a new option has been added to use button to trigger a script.Control over its appearance is also expanded.
The Basic Syntax is:

<Button [name=][value=][type=button|submit|reset]>Buttontext
<button>

The button takes three possible values Submit,Reset and Button.These value are all duplicates of their conterparts in Input element.

The Select and Option Element

The Select element is used to create a list of choice either as a drop-down menu or a list box. Each of the choice in list is an Option element.

<Select [name=][size=][multiple][disable]>
Option Elements </select>
<Option [selected][disabled][value][events]>Text lable or value </option>

The Form Element Input Element Button Element
Select And Option Element The Textarea Element The Lable Element

The Textarea Element

The Textarea element is similar to input element's text type. The diference is that users can type a larger section of text than text boxes.Instead of a single line of text, there's a large window where multiple-line responses can be typed.

<Textarea [name=][rows=][cols=][disabled][randomly]>
</Textarea>

Textarea is typically used for comments or delivery instructions-anything that requires more than simple response.The dimensions of the window is defined by rows and cols attributes. These attributes, Ofcourse,refer to number of rows and columns in the text window.

The Lable Element

The Lable element is new to HTML 4.0. As the name implies , it's the text that lables a control. Unlike normal text, however, the lable and its associated controls both share the same focus. In other words, if you click on the lable,it has the same effect as though you clicked on control itself.
Syntax:

<Lable [for=""][disabled][accesskey=]>
</Lable>

Lables are associated with controls in one or two ways, either .In the implicit association method, the associated element is contained in the lable element. with an explicit association, the lable is tied in by the control element's id attribute.

Top of this page

Home Overview W3C HTML4.0 Introduction Structure Interactivity
Table Appearance CSS Scripting Frameset XML Advanced Techniques