jim.shamlin.com

The Form

An HTML form is a group of input elements that will submit data to be acted upon to by a server-side or client-side application or script.


Basics

The FORM tag is a container inside which form elements, as well as any HTML tags to format them, is placed. Bare-bones code for a form is:

<FORM>
<!-- CONTENT -->
</FORM>

This effects no screen output.


Usage

A FORM tag is used to group a number of input elements and indicate what should be done with them. Originally, it was intended to gather data that would be submitted to the server, but it's also possible (and useful) to use a form to gather data that will be handled client-side by JavaScript.


Processing

No information about the form is submitted to the server for processing, only the value of its elements.

It is worth mentioning that the form tag specifies the action, which determines how the data from the elements is passed to the server (as query-string data or among the HTTP headers).


HTML Attributes

Typical

Unusual


JavaScript

The elements contained within a form have their own properties, methods, and events. These are attributable to the form, itself.

Properties

Methods

Event Handlers


Misc Notes

It is possible to have multiple form objects inside a Web page, though performance becomes unpredictable if a form is nested within another form.

While it is possible to omit the METHOD and rely on the browser to use GET, that should be avoided, as not all browsers will do this.

If your form is meant for client-side processing, do not use a submit button, as it may force the page to refresh (even if the from's ACTION is set to null). Instead, usa a generic button.