Java Reference
In-Depth Information
Figure 7-4
As you can see, most form elements are created by means of the <input/> element. One of the <input/>
element's attributes is the type attribute. It's this attribute that decides which of the form elements this
element will be. Examples of values for this attribute include button (to create a button) and text (to
create a text box).
Each form element inside the web page is made available to you as — yes, you guessed it — an object.
As with all the other objects you have seen, each element's object has its own set of distinctive properties,
methods, and events. You'll be taking a look at each form element in turn and how to use its particular
properties, methods, and events, but before you do that, let's look at properties and methods that the
objects of the form elements have in common.
Common Properties and Methods
Because most form elements are created by the <input/> element, it would be correct to guess that all
form elements share several properties and methods in common.
Here are a few.
The name Property
One property that all the objects of the form elements have in common is the name property. You can use
the value of this property to reference that particular element in your script. Also, if you are sending the
information in the form to a server, the element's name property is sent along with any value of the form
element, so that the server knows what the value relates to.
The value Property
Most form element objects also have the value property, which returns the value of the element. For
example, for a text box, the value property returns the text that the user entered in the text box. Also,
setting the value of the value property enables you to put text inside the text box. However, the use of
the value property is specifi c to each element, so you'll look at what it means as you look at each indi-
vidual element.
The form Property
All form element objects also have the form property, which returns the Form object in which the element
is contained. This can be useful in cases where you have a generic routine that checks the validity of data
Search WWH ::




Custom Search