|< Day Day Up >|
11.1 Form Basics
A form begins and ends with the HTML <form> tag. The opening <form> tag indicates the beginning of the form and sets its properties; the closing </form> tag, of course, marks the form's end.
In between these tags, different objects provide the basic user interface elements梩he design梠f the form. Radio buttons, text fields, and pull-down menus (also called pop-up menus) are just a few of the ways you can gather input. It's perfectly OK to include other HTML elements inside a form, too. In fact, your site's visitors would be lost if you couldn't also add (and format) text that explains the purpose of each form object. And if you don't use a table or Cascading Style Sheets to lay out a form in an organized way, it can quickly become an unreadable mess (see the box in Section 11.3.3).
Every form element, whether it's a text field or a checkbox, has a name and a value. The name indicates what information the element is intended to collect. For example, if you want your visitors to type their email address into a text field, the name of that field might be email. The value, on the other hand, is the person's input梬hat your visitors type into the text field, for example, or the selections they make from a pull down menu.
After your visitors fill out the form and click the Submit button to transmit their responses, each form element is transmitted as a name/value pair like this: email@example.com. Submitting both pieces of information helps the program that processes the form figure out what the input means. After all, without a name, a value of 39 doesn't mean much (39 what? Potatoes, steps, days until Christmas?). The name/value pair (age=39) provides context for a visitor's input.
11.1.1 The Code Backstage
Writing the necessary behind-the-scenes processing software can be complex, but the concepts behind forms are straightforward:
So how do you create the processing half of the forms equation if you're not a programmer? You can use Dreamweaver MX, of course. Part VI of this book describes Dreamweaver's dynamic Web-building tools for creating pages that use information collected from forms in a database. If your Web server accommodates Active Server pages, ASP.NET, Cold Fusion, Java Server pages, or PHP, Dreamweaver can create form-processing programs for you.
If you're part of a Web development team in a company, you may already have inhouse programmers who can help you create the processing program.
Furthermore, even if your Web hosting company doesn't tolerate any of the application servers that work with Dreamweaver, they probably offer free form-processing programs as part of their services. Contact your Web host and ask about this. If so, the company will provide instructions on how to use these programs.
Finally, if you feel adventurous, many form-processing programs are available for free on the Web. For a thorough sampling, see the CGI Resource Index at cgi.resourceindex.com/ . Using these free programs can be tricky, however, because you need to download the appropriate program and install it on your Web server. Your Web hosting company may not even permit you to do so.
|< Day Day Up >|