TAILIEUCHUNG - HTML in 10 Steps or Less- P9

HTML in 10 Steps or Less- P9:Welcome to HTML in 10 Simple Steps or Less. Our mission in writing this book is to provide a quick and accessible way for you to learn Hypertext Markup Language — the lingua franca of the World Wide Web. We hope this book provides a resource that beginning and intermediate HTML coders can use to improve their Web development skills. It is also our hope that it fills multiple roles as both a teaching tool and a reference once you expand your skills. | 136 Part 7 Task 0 Using Hidden Fields Each of the form controls you ve seen so far sends data to a script in response to an action taken by the visitor who types something into a field clicks a check box or radio button selects something from a menu or list and so forth. HTML provides a mechanism by which you can include values in your form to be sent to the script that visitors never see. These values are defined using hidden fields. note In this example the URL of the processing script see the form tag s action attribute is on another Web site. The hidden field tells the script which Web site this data came from. 1. Insert an input tag. 2. Define a type attribute and set it equal to hidden input type hidden 3. Define a name attribute and set it equal to the appropriate value specified by the processing script input type hidden name customer_site 4. Define a value attribute and set it equal to whatever information you want the field to pass to the script when the form is submitted input type hidden name customer_site value Alpha-Gizmo 5. To make the input tag compatible with XHTML and keep it recognizable to non-XHTML browsers conclude the tag by inserting a space after the last attribute value and adding a forward slash and closing bracket input type hidden name customer_site value Alpha-Gizmo Listing 62-1 shows an example of a hidden field that sends data to a script. Figure 62-1 shows how that data could be used by a script to generate a special message to the visitor. Figure 62-1 The script returns a second page that makes use of the information supplied by the hidden field Please purchase PDF Split-Merge on to remove this watermark. Working with Forms 137 html head title Hidden Fields title head body form action http cgi-bin method post input type hidden name web_site value Alpha-Gizmo Select the Newsletters you wish to receive br br input type checkbox name newsletter value oral_hygiene Oral Hygiene Weekly br .

TỪ KHÓA LIÊN QUAN
TÀI LIỆU HOT