The first step in using the Form Page Wizard is to add a new page to an existing Web by clicking File, New, Page. A list of templates and wizards that can be employed on the new page is shown.
When the Form Page Wizard is selected, you can immediately add questions to the form. You also can either remove or modify existing questions, which makes it easy to change things on-the-fly as you're working with the wizard.
The wizard requires two things in order to add questions to a form: a prompt and an input type. A prompt is a succinct line of text that asks a question or describes a group of related questions. The input type represents the structure of the information collected in response to the prompt.
Ask a Simple Question
Several of the wizard's input types determine how a single question can be answered . They include the following:
Figure 40.1 shows the Form Page Wizard being used to add the question "Have you ever been convicted of a crime?" The input type for this question has been set to boolean , which limits responses to an either/or proposition such as yes or no. The string or paragraph input types could have been used instead, giving someone a chance to provide a more unstructured answer such as "Not since I quit using illegal drugs."
Figure 40.1. Adding a boolean question to a form.
Each of these questions can be customized once the input type and prompt have been defined. You can limit date and time answers to specific formats, restrict a string answer to a specific number of characters , and make other decisions that affect how the form will be used.
One of the things you must customize about a question is the name of its variable , which is a place in a computer program where information can be stored for later use. Variables are used in Web forms to keep track of how questions have been answered. Each variable is given a name that can be used to retrieve or modify its value.
A variable's name should describe its purpose. You can use any combination of letters , numbers , and the underscore character (_) when you're naming variables. For example, three appropriate names for the "convicted of a crime" question are Convictions, Any_Convictions , or CriminalRecord .
Choose from a List of Options
There are two input types in the Form Page Wizard that enable answers to be selected from a list of possible choices:
The prompt should identify what the list is being used to answer.
Each choice in a list must be a single line of text. Single-choice lists can be presented in three different ways on a Web page: a drop-down menu, radio buttons , or a list. All of these are shown on the portion of a Web page displayed in Figure 40.2.
Figure 40.2. Three ways a list of options can be presented.
As shown, a drop-down menu shows only one possible answer at a time. If you click the arrow next to the answer, a menu of other answers will appear. Radio buttons and lists show several possible answers.
A multiple-choice list enables the user to select more than one answer from a list. Each possible answer is shown next to a check box. A single-choice list restricts the answer to a single item in the list. Both types of lists must have a named variable to store answers in.
Multiple-choice lists require a group of variables ”one for each possible choice that can be selected. Instead of providing a name for each of these variables, you provide a base name . This will be combined with the text of each answer to form variable names.
Figure 40.3 shows the Form Page Wizard being used to create a multiple-choice list. The list is used to answer the question "Which of the following languages do you speak?" One of four answers can be selected: English, Spanish, German, or Esperanto.
Figure 40.3. Providing answers and a base variable name for a multiple-choice list.
The base variable name is Speaks . The answers to this question will be saved in the variables Speaks_English, Speaks_Spanish, Speaks_German , and Speaks_Esperanto .
Ask Multiple Questions at Once
The remaining input types in the Form Page Wizard are used to ask several related questions at the same time. They include the following:
The Form Page Wizard automatically provides a prompt for each question in the group. If you provide your own prompt, it will be used to introduce the entire group rather than for any specific questions.
These combined input types make it easy to add some of the most common questions to a form. You can customize these questions by removing any questions that you don't want to ask.
In Figure 40.4, the Form Page Wizard is being used to customize a group of questions after the contact information input type was selected. The figure shows all of the customization options offered with the contact information input type. The Name and E-mail address questions are selected.
Figure 40.4. Selecting which contact information questions to use on a form.
For some of these input types, the variable names will be provided by the wizard. Otherwise, a base variable name must be provided for the group of questions. This will be used by the wizard to associate a variable name with each question.
Determine How the Form Will Be Presented
After you've finished adding questions to a form, you can choose how the questions will be presented on a Web page. You can lay out the form as a series of paragraphs or as one of three different lists:
A definition list is a standard Web page element that's ideal for displaying a group of words and their definitions. The formatting varies depending on the browser being used. Generally, words are presented flush-left, and definitions are indented below the word they define. The following text is presented in the style of a definition list:
Do A deer; a female deer Ra A drop of golden sun Mi The name I call myself Fa A long, long way to run
On a form that's displayed as a definition list, questions are presented flush-left and possible answers are indented.
Another presentation decision you must make is whether to use tables when laying out your form. Tables can be used to arrange elements on a page. If you decide to use a table, the Form Page Wizard will place questions and answers into their own cells on the table, making the form appear more organized. The borders of this table will not be visible when the form is created.
If you decide not to use a table, questions and answers will be arranged more loosely as a series of paragraphs.
Figure 40.5 shows a Web page that contains two versions of the same three-question form ”a survey for owners of a company's bread- makers . The upper version of the form is formatted with a table, which lines up the questions and possible answers evenly in two columns . The lower version does not use a table.
Figure 40.5. Arranging a form with and without a table.
Save the Information Collected on a Form
The last step in creating a form with the Form Page Wizard is to decide how a user's answers will be saved. The following three options are available:
To save a form's answers to a Web page or text file, you must be publishing your Web on a server that is enabled with FrontPage Server Extensions.
All answers submitted using the form will be saved to the same page. A question is identified on this form using its variable name followed by a semicolon. The answer to that question is presented on the following line. Figure 40.6 shows two sets of form results saved to a Web page.
Figure 40.6. Viewing a form's results that have been saved to a Web page.
Displaying results as a Web page is useful when you want to view the answers in an easy-to-understand format.
If you're going to use form results with other software (such as Microsoft Access or another database program), they should be saved to a text file. This file can easily be imported into a database program. The first line of the file will identify each of the form's variables, and each subsequent line will contain a set of results.
The following output contains the same form results shown in Figure 40.6, saved to a text file instead:
[View full width]
This text file uses Tab characters to separate each field: Personal FullName , Personal DateOfBirth , Personal Sex , and Personal Height . A format like this is less readable to humans than HTML, but much more readable to database software.
When you save form results, you must name the file that will be used to store them. The Form Page Wizard will provide an .htm or .txt file extension for you, so all you'll need to choose is the name that precedes the extension. Results are saved in the same folder as the Web page that contains the form, unless you specify a different one along with the filename.
The file that contains form results can be loaded within FrontPage. If you'd like to delete all existing results, delete the file. A new file will be created automatically when new results are submitted using the form.
The final option for saving form results is to use a custom Common Gateway Interface ( CGI ) script. CGI refers to the use of special programs ”also called scripts ”that are run in conjunction with Web pages. A Web server that supports FrontPage offers a lot of the same functionality as a CGI program. The main use of CGI on the World Wide Web is to handle the results of Web forms.
CGI programs require special access to the Web server that's hosting your Web. You'll need to know the name of the CGI program to run and its location on the Web site.