In the preceding section, we introduced basic forms. In this section, we introduce elements and attributes for creating more complex forms. Figure G.4 contains a form that solicits user feedback about a Web site.
Figure G.4. Form with text areas, a password box and checkboxes.
The textarea element (lines 3739) inserts a multiline text box, called a text area, into the form. The number of rows is specified with the rows attribute, and the number of columns (i.e., characters) is specified with the cols attribute. In this example, the textarea is four rows high and 36 characters wide. To display default text in the text area, place the text between the </tt></span></span> and <span style="color: #000000;"><span><tt> tags. Default text can be specified in other input types, such as text boxes, by using the value attribute
The "password" input in lines 4647 inserts a password box with the specified size. A password box allows users to enter sensitive information, such as credit card numbers and passwords, by "masking" the information input with asterisks (*). The actual value input is sent to the Web server, not the characters that mask the input.
Lines 5471 introduce the checkbox form element. Checkboxes enable users to select from a set of options. When a user selects a checkbox, a check mark appears in the check box. Otherwise, the checkbox remains empty. Each "checkbox" input creates a new checkbox. Checkboxes can be used individually or in groups. Checkboxes that belong to a group are assigned the same name (in this case, "thingsliked").
We continue our discussion of forms by presenting a third example that introduces several additional form elements from which users can make selections (Fig. G.5). In this example, we introduce two new input types. The first type is the radio button (lines 7694) specified with type "radio". Radio buttons are similar to checkboxes, except that only one radio button in a group of radio buttons may be selected at any time. The radio buttons in a group all have the same name attributes and are distinguished by their different value attributes. The attribute-value pair checked = "checked" (line 77) indicates which radio button, if any, is selected initially. The checked attribute also applies to checkboxes.
Figure G.5. Form including radio buttons and a drop-down list.
(This item is displayed on pages 1505 - 1508 in the print version)
1 "1.0"?> 2 "-//W3C//DTD XHTML 1.1//EN" 3 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> 4 5 6 7 8 |
"http://www.w3.org/1999/xhtml"> 9 | 10 | Internet and WWW How to Program - Forms 11 12 13 | 14 15
Feedback Form16 17Please fill out this form to help 18 us improve our site. 19 20 "post" action = "/cgi-bin/formmail"> 21 2223 "hidden" name = "recipient" 24 value = "deitel@deitel.com" /> 25 "hidden" name = "subject" 26 value = "Feedback Form" /> 27 "hidden" name = "redirect" 28 value = "main.html" /> 29 30 31Name: 32 "name" type = "text" size = "25" /> 33 34 35Comments: E-mail Address: 41 "email" type = "password" 42 size = "25" /> 43 4445 Things you liked: 73 How did you get to our site?: 99 Rate our site: 100 101 102 103 104 "rating"> 105"selected">Amazing 10610 [Page 1507]1079 1088 1097 1106 1115 1124 1133 1142 1151 116Awful 117 118 119 120 121 122123 "submit" value = 124 "Submit Your Entries" /> 125 "reset" value = "Clear Your Entries" /> 126 127 128 129 130 131 |
|
The select element (lines 104117) provides a drop-down list of items from which the user can select an item. The name attribute identifies the drop-down list. The option element (lines 105116) adds items to the drop-down list. The option element's selected attribute specifies which item initially is displayed as the selected item.
Preface
Index
Introduction to Computers, the Internet and Visual C#
Introduction to the Visual C# 2005 Express Edition IDE
Introduction to C# Applications
Introduction to Classes and Objects
Control Statements: Part 1
Control Statements: Part 2
Methods: A Deeper Look
Arrays
Classes and Objects: A Deeper Look
Object-Oriented Programming: Inheritance
Polymorphism, Interfaces & Operator Overloading
Exception Handling
Graphical User Interface Concepts: Part 1
Graphical User Interface Concepts: Part 2
Multithreading
Strings, Characters and Regular Expressions
Graphics and Multimedia
Files and Streams
Extensible Markup Language (XML)
Database, SQL and ADO.NET
ASP.NET 2.0, Web Forms and Web Controls
Web Services
Networking: Streams-Based Sockets and Datagrams
Searching and Sorting
Data Structures
Generics
Collections
Appendix A. Operator Precedence Chart
Appendix B. Number Systems
Appendix C. Using the Visual Studio 2005 Debugger
Appendix D. ASCII Character Set
Appendix E. Unicode®
Appendix F. Introduction to XHTML: Part 1
Appendix G. Introduction to XHTML: Part 2
Appendix H. HTML/XHTML Special Characters
Appendix I. HTML/XHTML Colors
Appendix J. ATM Case Study Code
Appendix K. UML 2: Additional Diagram Types
Appendix L. Simple Types
Index