December 2003
Intermediate to advanced
764 pages
24h 58m
English
The HTML specification defines a set of elements for presenting a form with fields in which the user can enter text or select among predefined choices. I’m sure you have encountered these countless times—to tell a vendor about yourself when downloading demo software, to specify what you’re looking for on a search engine site, or to select the toppings when you order a pizza online. But you may not be familiar with what’s going on behind the scene when you fill out the form and click Submit. Example 8-1 shows an HTML page that contains the most commonly used HTML form elements.
<html>
<head>
<title>User Info Entry Form</title>
</head>
<body bgcolor="white">
<form action="process.jsp" method="post">
<table>
<tr>
<td>Name:</td>
<td>
<input type="text" name="userName">
</td>
</tr>
<tr>
<td>Birth Date:</td>
<td>
<input type="text" name="birthDate">
</td>
<td>(Use format yyyy-mm-dd)</td>
</tr>
<tr>
<td>Email Address:</td>
<td>
<input type="text" name="emailAddr">
</td>
<td>(Use format name@company.com)</td>
</tr>
<tr>
<td>Gender:</td>
<td>
<input type="radio" name="gender" value="m" checked>Male<br>
<input type="radio" name="gender" value="f">Female
</td>
</tr>
<tr>
<td>Lucky number:</td>
<td>
<input type="text" name="luckyNumber">
</td>
<td>(A number between 1 and 100)</td>
</tr>
<tr>
<td>Favorite Foods:</td>
<td>
<input type="checkbox" name="food" value="z">Pizza<br> <input type="checkbox" name="food" value="p">Pasta<br> ...Read now
Unlock full access