Main Page

input elements

A form can contain any number of input elements:
?
<input/>
— The main HTML input element. The type attribute determines what type of input
control is displayed:
?
“text”
— A single-line text box
?
radio”
— A radio button
?
“checkbox”
— A check box
?
“file”
— A file upload text box
?
“password” –
A password text box (where characters are not displayed as you type)
?
“button”
— A generic button that can be used to cause a custom action
?
“submit”
— A button whose sole purpose is to submit the form
?
“reset”
— A button whose sole purpose is to reset all fields in the form to their
default values
?
“hidden”
— An input field that isn’t displayed on screen
?
“image”
— An image that is used just like a Submit button
?
<select/>
— Renders either a combo box or a list box composed of values defined by
<option/>
elements
?
<textarea/>
— Renders a multiline text box in a size determined by the
rows
and
cols
attributes.
Here is a simple form using the various input elements:
<html>
<head>
<title>Sample Form</title>
</head>
<body>
<form method=”post” action=”handlepost.jsp”>
<!-- regular textbox -->
<label for=”txtName”>Name:</label><br />
<input type=”text” id=”txtName” name=”txtName” /><br />
<!-- password textbox -->
<label for=”txtPassword”>Password:</label><br />
<input type=”password” id=”txtPassword” name=”txtPassword” /><br />
<!-- age comboxbox (drop-down) -->
<label for=”selAge”>Age:</label><br />
<select name=”selAge” id=”selAge”>
<option>18-21</option>
<option>22-25</option>
<option>26-29</option>
<option>30-35</option>
<option>Over 35</option>
</select><br />
336
Chapter 11
14_579088 ch11.qxd 3/28/05 11:40 AM Page 336


JavaScript EditorFree JavaScript Editor     Ajax Editor


©