Adding a Form to a Page


You could start creating a page by throwing fields onto it, but when your visitor clicks Submit, the browser won't know what to do with the data. That's where you need a formit tells the browser that all this information is part of one package, and it tells the browser what it should do with all of the information that it's gathered.

To add a form to a page:

1.
Choose where on your Web page you want your form, and click the form button on the Insert Bar. A red box will appear on your page ( Figure 10.2 ).

Figure 10.2. A form looks bare until you add the form fields.


2.
If that box hasn't been automatically selected, select it, and you'll see the options you can change for your new form in the Property Inspector ( Figure 10.3 ). The ones that apply solely to forms are:

  • Form name : If you're going to be doing any JavaScript validation of your form, it's a good idea to give it a name. In addition, some CGIs (which stands for Common Gateway Interface) need their associated forms to have a particular name.

  • Action: This is the program on the Web server that is executed when the form is submitted. You'll need to get the name of this from your system administrator or hosting provider. It's also commonly referred to as a System CGI.

  • Method: The most common options are GET and POST. POST passes the form data as part of the header of the request to the server. GET passes the data as part of the URL of the request to the server. Because of this, and because GET has a length limitation, POST is what you'll usually want.

  • Enctype: This field describes the enclosure type being sent to the server. The default is application/x-www-form-urlencoded . The only time you'll want to use multipart/form-data is if you're asking your visitors to upload a file.

Figure 10.3. The Property Inspector is where you set a form's name, action, and method.


The Uncovered Fields

There are two form fields in the Insert Bar that aren't covered in this chapter:

  • Jump Menus: These will be covered in Chapter 12, Using Behaviors and Navigation Objects .

  • File field: If you need to upload a file to a server, you'll want to use this type of form field. It's fairly self-explanatory, but you'll need to talk to your server administrator about how they've set up their server to accept files.


Tips

  • Make sure that all your form fields are inside your form; if they are not, their contents won't be sent to the server. It's a good idea to put the entire page inside the form.

  • If you try to add a form field to a page that doesn't have a form, you'll be asked if you want to add a form tag. You might think from this that it's not worth bothering to add a form tag manually first, but it is. You'll have better control over where the form is placed, and what ends up going inside it.

  • No, that red border around the form won't actually display on your site. It's just there in Dreamweaver so that you'll know where the form begins and ends.





Macromedia Dreamweaver 8 for Windows & Macintosh Visual QuickStart Guide
Macromedia Dreamweaver 8 for Windows & Macintosh
ISBN: 0321350278
EAN: 2147483647
Year: 2005
Pages: 239

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net