Sunday, March 28, 2010
Forms
HTML forms provide a method to use standard GUI elements to display and collect
data. HTML forms provide the standard litany of GUI elements, including text boxes,
check boxes, pull down (also referred to as drop-down) lists, and more. In addition
to providing basic GUI elements, HTML forms also provide a rudimentary method of
collecting data and passing that data to a data handler for validation, storage,
comparison, and so on.
A typical HTML form resembles the following code, the output of which is shown in
Figure .
<html>
<body>
<form>
<!-- Text field -->
<b>Name:</b> <input type-"text" name-"name" size-"40">
<br><br>
<!-- Radio buttons -->
<b>Age:</b>
<input type-"radio" name-"age"> < 20
<input type-"radio" name-"age"> 21 -- 30
<input type-"radio" name-"age"> 31 -- 40
<input type-"radio" name-"age"> 41+
<br><br>
<!-- Select list -->
<b>What is your favorite ice cream?</b>
<select name-"icecream">
<option name-"chocolate">Chocolate
<option name-"strawberry">Strawberry
<option name-"vanilla">Vanilla
</select>
<br><br>
<!-- Check boxes -->
<b>How may we contact you for more information?</b><br>
<input type-"checkbox" name-"phone">Phone<br>
<input type-"checkbox" name-"mail">Mail<br>
<input type-"checkbox" name-"email">Email<br>
<input type-"checkbox" name-"no">Do not contact me<br>
</form>
</body>
</html>
has no handler to process the data that is collected by the form. Real-world forms
can be quite complex and usually require validation scripts to ensure the data
collected is valid. However, this simple form illustrates the amount of control you
can assert over data and format using HTML.



Currently have 0 comments: