HTML and CSS Reference
In-Depth Information
The elements and properties of the HTML <form> tag are shown in Table 11.8.
Table 11.8 <form> Tag Elements and Properties
Object
Property
Purpose
button
name, type, value
A general-purpose GUI button.
checkbox
checked, defaultChecked, name,
type, value
A set of (or one) clickable boxes allowing multiple
selections.
FileUpLoad
name, type, value
A field allowing a file to be submitted as part of a
form.
hidden
name, type, value
A field where the content is not shown in the
form.
password
defaultValue, name, value
A field for entering a password, masking the real
characters typed.
radio
checked, defaultChecked, name,
type, value
A set of (or one) clickable boxes allowing only one
selection.
reset
name, type, value
A button that clears and resets the form fields.
select
length, name, options,
selectedIndex, type, value
A popup or scrolling list of items from which to
choose.
submit
name, type, value,
A button used for submitting form data.
text
defaultValue, name, type, value
A rectangular field allowing one line of input.
textarea
defaultValue, name, type, value
A rectangular box allowing multiple lines of input
value.
How JavaScript References the Form Elements by Name. Each form object
is an element of the forms[] array and each form contains input types such as buttons,
textboxes, checkboxes, and so on. Each of the input types is also stored in an array called
elements[] in the order in which the input device is found in the document. In the fol-
lowing example, there is one form, called myform . It contains two elements, button
input types, named button1 and button2 , respectively. The JavaScript program gets access
to the form and button properties by using names to reference them. An object can be
referenced by using the numeric array notation, or referenced by its name with the dot
notation; that is, object first, then dot and name, or by putting the name as a string in
square brackets (associative array). If there are a number of forms and buttons, using the
associative array notation, rather than the numerically indexed array notation, might
make it easier to locate the object. For instance, if one of the forms or input devices has
been moved or deleted, the numeric index values for all of the objects on the page would
 
Search WWH ::




Custom Search