Forms

One of the powerful features of JavaScript is its ability to manipulate HTML forms. HTML defines the following form elements:

Button (<INPUT TYPE=button>)

A graphical push button; onClick events

Checkbox (<INPUT TYPE=checkbox>)

A toggle button without mutually exclusive behavior; onClick events

FileUpload (<INPUT TYPE=file>)

A file entry field and file browser; onChange events

Hidden (<INPUT TYPE=hidden>)

A nonvisual data field; no event handlers

Option (<OPTION>)

An item within a Select list; event handlers are on the Select object, not Option objects

Password (<INPUT TYPE=password>)

An input field for sensitive data; onChange events

Radio (<INPUT TYPE=radio>)

A toggle button with mutually exclusive “radio" behavior; onClick events

Reset (<INPUT TYPE=reset>)

A button that resets a form; onClick events

Select (<SELECT[MULTIPLE]> . . . </SELECT>)

A list or drop-down menu from which one or more Option items may be selected; onChange events

Submit (<INPUT TYPE=submit>)

A button that submits a form; onClick events

Text (<INPUT TYPE=text>)

A single-line text entry field; onChange events

TextArea (<TEXTAREA> . . . </TEXTAREA>)

A multiline text entry field; onChange events

Figure 11.3 shows a web page that contains each type of form element.

Form elements

Figure 11-3. Form elements

Get Webmaster in a Nutshell, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.