Lesson 6 - Forms Review



welcome to Wreamweaver 8

We have completed the first half of the our Dreamweaver Interactive course. You've created a practice homework site incorporating the tools and techniques learned in the first 6 lessons, plus the additional features from topics including templates, and library items. This next assignment will show you some basic integration of DW with open source databases, and server side technologies. These remaining lessons will introduce you to advanced aspects of forms, XML and RSS, and provide resources for becoming a stronger website developer / webmaster.

This is a very challenging assignment, and requires you to have some rudimentary knowledge of PHP, databases, and in particular, MySQL - if you are unsure about this, email me before jumping in! This page is a review of forms for anyone in this course who did not complete COIN74A, or needs a refresher. At the bottom of the page will be several forms that you can download.

Creating Simple Forms using Dreamweaver

HTML forms can be used for search engines, questionnaires, hotel reservations, registration and order forms, surveys, data entry, shopping carts and e-commerce, user feedback, and a wide variety of other applications. The form is specified as part of an HTML document. The user fills in the form and then submits it. The user agent then sends the form's contents to a recipient, as designated by the FORM element. Typically, this is to an HTTP server, but you can also email form contents. The form is one of the first interactive elements in web design. When the user submits the form, the information is sent to a server where a script acts on the data - sorting and organizing the contents before forwarding the results. The html author can create a confirmation notice to the user after the user submits the form.

You will create the form using Dreamweaver but all forms require a form handler to process the form data. You can not do this part with Dreamweaver since this part requires scripting on the server. A Common Gateway Interface (CGI) script runs on the server and is one way to process the information from the form (known as form data). CGI scripts can be used for tracking counters, message boards, email discussion groups, jump menus, etc. Many CGI scripts were written in Perl but there are other languages and scripts for processing forms such as AppleScript, C or C++, UNIX, Visual Basic.

Some CGI scripts have required fields which may be case sensitive. Check with your ISP or sysadmin to see if the mailform they use has any required fields.

Internet Service Providers (ISP) and universities often provide CGI scripts that can be used for free but these institutions restrict direct access to a CGI script. Contact your ISP to get specifics from them on their CGI and form processing features. Often they will have a generic Thank You or confirmation page where they redirect the user after they submit the form. You can create your own redirect confirmation page as well.

You can do a search for scripts and find many free scripts on the internet that you can plug into your HTML source. One of my favorites is: Matt's Script Archive.

Instead of using CGI you can use PHP, Hypertext Preprocessor, which is a scripting language that is run mainly on Linux Web servers. It is often used to access a database for information which is then formatted to be displayed in html. It is free and offered through an open source license. Go to the PHP web site to learn more about it.

Forms are created by placing input fields within paragraphs, preformatted text, lists and tables. The element in which a user enters data is called the input field. Information entered by the user is called the value. Before you can use any of the form fields, you must create the form itself.

Behind the Scenes of Forms

This is not an HTML course but this Lesson will be more valuable if you create your form using the split view 'Show Code and Design View' button. This way you can see behind the scenes (the HTML source) as you create the elements in bottom pane of the Document Window.

1. On the Document Window toolbar select the Split Button to split your screen into Code and Design Views.

2. Open the Forms Category of the Insert Bar or go to the Insert Menu - Insert>Form>Form to create a form.

Form Button

Select the Form button to insert a form into your file. Selecting this button will create the Form container tags represented by a red dotted-lined rectangle in your Document Window. The contents of the form will go between the open form tag <FORM> and the end form tag </FORM>, i.e. within the red dotted box.

form bounding box

If you don't see the red dotted line in your document window, go to the View Menu - Visual Aids>Invisible Elements and make sure that there is a checkmark to the left of Invisible Elements.  You can use the tag selector in the bottom status bar of the Document Window to select the form.

When you select the form by clicking on the red dotted-lined rectangle, the property inspector displays the properties for the form. Here are the Properties for the Form tag in the PI. 

form PI

Select the form and open the PI. For this lesson, leave the Target dropdown menu blank, the Class dropdown menu blank, set the Method to POST, and leave the Enctype dropdown field blank unless you're using an email address for the form action, in which case type the words "text/plain" without the quotes into the the Enctype field.

You can not drag the red dotted-lined rectangle to change the size of the form.  The size of this form container is dependent upon the elements you put inside the form. Here are the properties available in the PI for the form.

The Form Icon is represented in the upper left corner by a square with a dashed line.

The Form Name is form1 by default but I recommend changing the name to something descriptive. Do not use spaces, special characters or reserved words. Let's use feedback for our Form name. Replace "form1" with "feedback"without the quotes.  Note that DW will name the forms by default form1, form2, form3, etc.

The Action attribute is the destination of the form.  Most likely, the destination will be the URL of the CGI mailform and will usually end with cgi-bin or cgi_bin. Get the address of the cgi from your ISP. You can also have the results of the form data emailed to you, in which case you'd put your email address in the action field preceded by mailto: so the complete address would read mailto:someone@somewhere.com. Using the mailto presents some problems so it's best to get the cgi-bin from your system administrator or ISP or use the information at the end of this lecture to connect to the formmail site.

The Method attribute is determined by the way or method the form will be processed, either CGI or Web-based application. Check with your ISP to see which method to use. GET is not a secure way to send the info so should not be used for sensitive info or e-commerce. Most of the time you'll use POST.

The Form fields based on the above information using a CGI script would be displayed in your HTML source code as:

<form action="http://www.somewhere.com/cgi-bin" method="post" name="feedback">
    form goes here
</form>

or using PHP would be displayed in your HTML source code as:

<form action="http://www.somewhere.com/phpFileName.php" method="post" name="feedback">
    form goes here
</form>

or for those who are temporarily using an email as the form action, add text/plain for the enctype:

<form action="mailto:someone@somewhere.com" method="post" enctype="text/plain" name="feedback">
    form goes here
</form>

Once you Insert the Form you can add Form Elements into the red dotted line. Many designers use Tables to create the layout for their form elements and then add labels or descriptive text associated with each label. You must insert all your form elements inside the red-dotted rectangle.

Insert a table of 100% inside your form and make 8 rows and 2 columns. You can adjust the rows and columns later by entering new numbers in the Property Inspector for the rows and columns.  I recommend sketching a draft of your form on paper so you make sure you have all the proper form fields and labels to ensure that you'll collect the data you desire by making the form labels and input fields clearly laid out, defined, and intuitive for your user.  Match the table inside your form to your sketch. HTML 4 has a new tag called Fieldsets which help in creating the structure of your form by grouping content or chunking related content into groups. You will read more about Fieldsets in this lesson.

Here is the FORMS Category of the Insert Bar. Notice that the icon buttons are divided into groups.
I have identified each button with its associated group below the image of the Insert Panel.

Form Toolbar Buttons

  • Form
  • Text Field - Hidden Field - Textarea
  • Checkbox - Radio Button - Radio Group
  • List/Menu - Jump Menu
  • Image Field - File Field - Button
  • Label - Fieldset - Jump Menu Magic
  • Spry Validation Text Field - Spry Validation Textarea - Spry Validation Checkbox - Spry Validation Select

Form Elements have at least three important attributes (some, as we will see, have more); these are the label that will appear on the form to describe the form element for the user, the name of the form element (which is important to the browser), and the value that will be reported to you when the user submits the form. When you click on the icon for most of the common form elements on the Insert>Forms tab of the Insert menu, you will see the pop-up box below, where you will specify the label you wish to associate with your form element.  Enter the label you wish the user to see, leave the Style radio button on the default setting ("Attach label tag using 'for' attribute"), and choose the position for the label (before or after the form element) that suits your design. For now, ignore the Access key and Tab Index text boxes.

Form Label Definition

A few form elements require additional information, and will present a slightly more complex pop-up to you.  You can set all other values for an element using the PI for that element; to view an element's PI, simply click on the element in your Design View window.

Form Elements

Text Field

Using the PI, you can define the size of the field by specifying the character width and maximum number of characters the field will hold. If you select password, the input display will only show asterisk characters. This does NOT function as a password protected site, it merely offers visual protection. Contact your server admin for info on securing and/or encrypting data for password protection.

The textfield will be empty to users until they input text *unless* you put an Init val (initial value) in the PI at authoring time.  An initial value will be text that is displayed to the user when the page loads. Usually this text is instructional text or a prompt telling the user what you want them to do, and the user will select and type over the text.  I recommend not using Init val for a textfield since users many not realize that you want to collect input data from them and they may skip over a field that is already populated with text.

If you disagree and can give examples of times when Init val may be helpful to the user, please post your comments on the Discussion Board.  

The PI for Text Field

textfield PI
Hidden Field
hidden fields
hidden fields
Read further in this lesson to learn more about Hidden Fields. Hidden Fields do not display in the Document Window or the browser.  The image to the left appears in the Document window only. Check your code view and notice the code for your hidden field.  The default will be:
<input type="hidden" name="hiddenField">
PI for Hidden Field

PI Hidden Field
Text Area
textarea

Compare the PI for this Textarea to the PI for the Text Field. The main difference is that the Type radio button is set to "Multi line" and the Wrap dropdown menu is available in the Textarea.  I set my Wrap to virtual. The Wrap menu options are: Default, which is the browser default; Off, which stop text from wrapping and creates one long line of text; Virtual which wraps in the browser but text doesn't wrap when it's submitted to the server; Physical which wraps in the browser and text does wrap when it's submitted to the server.

You can toggle the Type radio set of buttons to convert a Multi line Textarea into a Single line Text Field and/or Password and vice versa.

Type several lines into the Textarea on the left to see what happens when the box "overflows".

PI for Textarea

PI textarea
Check Box
sailing
gardening
sewing
hiking
meditating

Checkboxes come in groups, and you must supply the group's name along with a label and value for each checkbox.   Use the PI to enter the group name -- in the example below, the group name is "hobbies".   Use the Checked value text field to enter the value the form will report when that individual box is checked. Note that the checkbox label and value can be identical.

  • the checkbox name must be the same for all checkboxes within one group.
  • each check box value must be unique within the checkbox group
  • all checkboxes are unchecked by default
  • a user can select multiple check boxes
PI for Checkbox

PI checkbox
Radio Button
10 - 19
20 - 29
30 - 39
40 - 49
over 50

Radio buttons come in groups, and you must supply the group's name along with a label and value for each radio button.   Use the PI to enter the group name -- in the example below, the group name is "hobbies".   Use the Checked value text field to enter the value the form will report when that individual button is selected. Note that the radio button label and value can be identical.

  • the radio button name must be the same for all radio buttons within one group: e.g. "age"
  • each check box value must be unique within the checkbox group
  • only one radio button can be selected for each group of radio buttons - think of a car radio button, when you select one, the other station goes off.  YOU CAN ONLY HAVE ONE SELECTION WITH RADIO BUTTONS.  Test yours before submitting. GET THIS RIGHT!

The name of the button group goes in the textfield below on the left, below the Radio Button text. The default says "radiobutton".  This is the name that will be the same for all the radio buttons of a given SET or GROUP.  The Checked value is the descriptive name you assign to each button within a set, for example if your Radio Button set were named Gender, your Checked values for two buttons in the group could be Male and Female.

PI for Radio Button

PI Radio Button
Radio Button Group
radio group

Choose the vegetable!



The Radio Group button was added to DW MX2004 to make it easier to create sets of radio buttons. Selecting the Radio Group icon and then filling in the Labels and Values in the radio group pop-up box should make it easy for you to get your Radio buttons right! 

Pop-up for Radio Button Group

Radio Button Group
Dropdown List/Dropdown Menu

The Dropdown List and Dropdown Menu share a PI.  Use the radio buttons on the PI to select the element you wish to use.  A Dropdown list will allow multiple selections from its list - the user can shift+click or control+click to select more than one option. The list will scroll if you have more items than the number you enter for the height of the list.

Click on the "List Values..." button to enter or edit elements in your list/menu.

A Dropdown Menu allows only one selection from its values.

PI for List/Menu

PI list/menu
Jump Menu
jump menu
 
Details of the Jump Menu are listed later in this lesson. You will submit a Jump Menu for this week's homework.  Please make sure that the Jump Menu is on a different .html page than the form that you will submit for this week's homework.
Image Field
 
Selecting the Image Field Button will open the Select Image Source dialog box where you can browser for an image to insert as a submit button.
You can use the image field to reset the form or attach a sound to a button using behaviors on the Form object which is covered in more advanced classes studying the use of behaviors in Dreamweaver.
File Field
I recommend that you NOT use this one your form. Anyone can upload a file with a virus attached and/or you may get spammed with files you don't want and didn't request. Use with caution.
Button


The button icon allows you to create the Submit and Reset buttons for your form.  Use the PI to choose which button to create, and to change the button value -- the text which appears on the button.

I recommend always putting the Submit button before the Reset or Clear button.  The reason is that users tend to use the Tab key on their keyboard to move to the next input area or form element.  This is called setting the focus in a form field. The default order will set the focus on whichever button is closest to the top of the form.  If a user is tabbing through and comes to the reset button, they might accidentally click and erase all their input.

You can set the tab order by using the Tab Index field of the Input Tag Accessibility Attributes Window.  To open this window, go to your Preferences and select the Accessibilities category.  Check the Form Objects box.

The None button can be used with scripts to perform calculations such as a script to return the sum of numbers.

PI for Button

PI Button
Label and Fieldset
label button
 
The label button lets you associate a text label for a field with the fieldset.
Read about a fieldset below.
fieldset
 

The fieldset button creates 2 container tags; a fieldset and legend as follows:
<fieldset><legend>fruits</legend></fieldset>

"The FIELDSET element defines a form control group. By grouping related form controls, authors can divide a form into smaller, more manageable parts, improving the usability disaster that can strike when confronting users with too many form controls. The grouping provided by FIELDSET also helps the accessibility of forms to those using aural browsers by allowing these users to more easily orient themselves when filling in a large form."

DW will automatically divide your Document Window into Split view when you select the fieldset button.

The fieldset is a new HTML4.0 element and you can read more about it here - the source of the above quote:
http://www.htmlhelp.com/reference/html40/forms/fieldset.html

Spry Validation Text Field
Spry Validation Text Field

Spry text fields have 14 different validation types as well as several other settings, such as an option to limit the minimum and maximum number of characters. None is the default setting which means no validation. You may set a pattern to validate against such as where numbers and letters are to be input. The following are the characters that are used to set the pattern:

  • 0 : A whole number from 0-9
  • A : Uppercase alphabetic letter
  • a : Lowercase alphbetic letter
  • B : Case insensitive alphabetic letter
  • X : Alphanumeric (uppercase letters and numbers)
  • x : Alphanumeric (lowercase letters and numbers)
  • Y : Case insensitive letters and numbers
  • ? : Any character (wild card)

Note that the characters in the pattern correspond to one character at a time. To set a pattern for B2B you would input XXX.

To show the Spry Validation Text Field in the Property Inspector you must click on the blue area where the Spry TextField label is. In this example it would be Spry TextField: sprytextfield1 in Design view.

PI for Spry Validation Text Field

Spry Text field PI
Spry Validation Textarea
Spry Validation Textarea
A value is required.

Spry textareas have far fewer validation options than text fields. You may specify whether the contents are required or not however you may not specify a patter. You have the option of showing the number of characters typed in and you may specify the maximum number of characters allowed. By setting a maximum value you may also choose to show the number of characters remaining.

PI for Spry Validation Textarea

Spry Validation Textarea PI
Spry Validation Checkbox
Spry Validation Checkbox
Please make a selection.

Spry Validation Checkbox ensures that a particular checkbox has been selected. A single checkbox is useful for situations that require the user to agree to your rules and conditions.

Adding a group of checkboxes is more complex and may be done in Code view or in Design view by following a rigorous set of steps. Look in "Dreamweaver CS3 The Missing Manual" by David Sawyer McFarland to see the steps required in order to accomplish this.

PI for Spry Validation Checkbox

Spry Validation Checkbox PI
Spry Validation Select
Spry Validation Select
Please select an item.

Spry Validation Select validates the selection of pull-down menus and has two options to determine whether the selection is valid or not. They allow you to not allow a blank value or an invalid value.

A pull-down menu is created with a label and a value. The label is what the user sees and the value is what gets sent to the server. If the value is invalid the form will not be submitted and an error message will be displayed.

PI for Spry Validation Select

Spry Validation Select PI

The form above is a non-functioning form so if you click the submit or reset button, no action will be taken.

List Values Dialog for List/Menu Buttons

List menu

Use the tab key to add new Item Labels and Values. The Labels appear to the viewer in the list and the Values are submitted and parsed by the form handler. Notice that the Value can be the same word as the label. If the Value is the same word or a different word than the Item Label, it should be descriptive.

Add items with the + and delete items with the -. Use the triangular arrows on the right to reorder the list items.

Hidden Fields

Hidden fields are invisible in the html page but viewable in the source of the HTML document. You can put your hidden fields anywhere in your form but the standard location is at the beginning of the form. It's helpful to add a comment describing the purpose of the field. You can add comments to your document by going to the Common Panel of the Insert Bar and using the Comment Button.

Comment

Comment Box

This yellow exclamation point icon is the comment icon in the DW document window. Select this icon to open the Property Inspector for the selected comment. You must enable View>Visual Aids> Invisible Elements.

Jump Menus

A Jump Menu is a form element which displays as a dropdown menu of linked URLs used for navigation. Since it is a form element, jump menus must be contained within the form beginning and ending tags. Dreamweaver's Insert Jump Menu feature adds JavaScript behaviors to the form menu element. Although the jump menu is a form element, all the processing is done on the client side through JavaScript and the jump menu does not require a form handler or a submit button. Please create a new form in which to contain your jump menu rather than grouping it with another form that requires a handler or cgi script on the server side.

Create a basic jump menu. Do not include a jump menu within any other form tag. It should always be in it's own separate form. GET THIS RIGHT PLEASE.  You won't  believe how many students put their jump menu within their form homework.  Create a jump menu on a separate html page than your submissible form.

To make the first item of your jump list instructions, set the Go to URL to the null (javascript:void(''); Note that the quotes within the parantheses are two single quotes) symbol and add your instructional text in the appropriate Text: field of the Insert Jump Menu window.

You can link your jump menu selections to any external absolute URL or any relative files in your site, including graphic and .pdf files. You can use behaviors to replace the standard Go button with an image when you learn more advanced features of DW.

Here is a jump menu:

To get your jump menu to open each URL in the current window or a frame, see these Adobe Tech Notes and Tutorials: Jump Menus

TechNote: How to insert a Jump Menu

The Go Button - make sure that the Go button is ONLY there if you are not programming the menu to jump automatically when an option is selected.  This is really important so read carefully.
TechNote: Jump Menu and Go Button Options

Targeting Frames from the Jump Menu:
TechNote: Setting a Target Frame in a Jump Menu

Go to Project 7's Web site check out their amazing extensions.

Adobe's Tech notes

Please visit Adobe's Tech notes Index for specific problems OR when you get stuck and no one has replied to your forum post!

TechNote Index

Form Validation

Dreamweaver has a behavior which will validate your form. In other words if you want a proper email address in an email field, this behavior will check the formatting of the entry and notify the user with an alert box if they have not used a standards blank@blank.com email address. You can use this behavior to make some or all fields required. If the user submits without filling in the required fields, an alert box will display a message that you create informing them they need to fill out the required fields, etc.

Please keep the form assignment so that you can apply the form validation behavior when we learn to use behaviors later in the course. (soon!) You will be required to use form validation on the form page of your final project.

Form Tips

Always contact your ISP or sysadmin for specific instructions on uploading forms to your server.

Use a unique name for each hidden field you use.

If you're allowing multiple selections for a form field, inform the user with a short text explanation and info on how they can select more than one item for a group. Modifier keys may be different for different operating systems.

Radio buttons always come in groups or sets. Each option within a set has a value and each option must be part of the same named group or set. Radio buttons are used when only one option at a time can be selected, just like the radio buttons on an old car radio.  When you select another button, it turns off the station that was previously selected ...hence the name:  radio button!

Checkboxes always come in groups or sets. Each option within a set has a value and each option in a set must be part of the same named group or set. Use checkboxes for multiple selections.

You can use the Submit button action set to None after you learn to use behaviors on form objects. Dreamweaver behaviors are written in JavaScript. You don't need to know JavaScript to use the behaviors with the form button.

For textarea Wrap property, use either Virtual or Physical to let the text automatically wrap within the text box. The difference in these options is how the text is sent to the CGI script. Wrap Physical preserves line wrapping that takes place in the text box and Virtual does not. Off displays all the text on a single line with horizontal scrolling until the Enter key is pressed. It's sent to the CGI as one single line of text.

You can set initial state of radio buttons and checkboxes within the Property Inspector. Select the form element and view the PI. I've selected unchecked for my samples above.

You can set an Initially Selected Option for List and Menu items. This can be a description or instruction rather than an option.

Radio Buttons are toggle. You can only select one option and you can have more than two choices per group or set of radio buttons. Think of them as buttons on an old car radio.  You can only have one radio station playing at a time on one radio right?  You push one button in and the other pops out.  Same with Radio Buttons in forms. Radio buttons always come in groups or sets.  Within each set, only one Radio Button can be selected.

Name every element you use in your form.

You can not nest forms which means you can not insert another form within a form. You can however have more than one form on a page but I don't recommend it and I will not accept more than one form on a page for your final project. Just be certain to end one form before beginning another form.

Use tables to get a nice layout structure for your forms.

Jump Menus: You can not add the GO button after you've closed the Insert Jump Menu dialog so it may be best to add it and then delete it if you decide you don't want it later. For your final project make sure that you design the function of the jump menu to either immediately go to the selected URL - in which case you DON"T need the GO button so remove it OR you want to select a URL and then require the user to click the GO button to jump to the selected URL.

Using Formmail: Contact your web host to find out the URL they want you to enter for the Form Action. This will enable people to fill out the form online and have the results submitted to you via email (in the most basic use of this feature).

For those using Foothill's UNIX server or who don't have a cgi bin with their web hosting service, sign up for a free trial account at Formmail.com - which is Matt's Script - and this service will process your form. I think you can register for $1/month after your trial. Worth it.

http://www.formmail.com/register/

Examples of how to use Hidden Fields

Do an Internet or reference book search for Hidden Fields. A classmate informed me that the link that was here and worked last month, is no longer active, so I removed it. This reflects the ever-changing nature of the web as a living and dying organism.  Sites come and sites go. Please inform me if/when you find broken links.  They are all active as of the date I uploaded this page.

"By way of example, lets imagine that you have a small newsletter signup box in several pages of your web site. When a user signs up for the newsletter, you might want to know from which pages they are signing up from and which ones they aren't. After a while, you might notice some trends about which page(s) users prefer to sign up from and which pages they don't. Then you could ask a question like 'Why do my visitors prefer to sign up from that page more often than this page?' This information might help you better design your site."

Read a few sites to learn more about both client- and server-side applications of hidden fields. Hidden fields are variables which are passed to the Forms Processor, like any other piece of data entered into a form by a client, except that hidden fields and their values do not show up in the browser. Hidden fields can be used to store information for server-side processing that are related to the information entered at the client side. For example, a CustomerID can be assigned when customer fills out an inquiry form. The CustomerID can then be sent to the server and stored in the database along with other customer information. Another example will be when a web site has multiple forms, a hidden field at the beginning of each form can be used to clear identification when any of the forms is submitted. I just wanted to point out that if there are multiple forms to fill out, hidden fields can contain this info and populate the rest of the forms after you have filled out the first one. Saves time when you track a user across multiple dynamically generated forms so that you can pre-fill user data for things that user already entered. A password will not be displayed on the screen as the person types it in. The price of items being purchased might be in a field that is hidden for some documents, such as a shipping form. When a person fills out a form to purchase an item by credit card , the credit card number, or perhaps all but the last four digits, might be in a hidden field. As the creator of the form, you might want to know the URL of the form, or the version number of the form, sent back to you as a hidden field. Hidden fields should be used when sensitive information is being communicated. Examples include password information and credit card information. The use of hidden fields range from sensitive data to developer's comments in case you're part of a team working on the same site. However, a hidden field is not a comparable substitute for cookies. A hidden field is not secure since all the data is stored in the source. Leaving the page and coming back to it does not retain the data like persistent cookies can.

Hidden fields can be useful for collecting user data. For example, lets say you are a webmaster in a marcom organization and you are asked to create a form to collect user data for a promotion your company is running. The objective is to pre-qualify potential customers so that members of the sales force can follow up with them. But what if you've already used that form for an earlier campaign? The sales force doesn't want to work a dead-end lead and risk alienating a potential sale. If you add a hidden field to your form that denotes campaign-specific data, you can now analyze the data from repeat customers and search for trends and craft strategies that best target that particular customer. - Jeff Cooper

Client-side and server-side field data will be treated by the server in the same manner as the data inputted by the client. The only difference is that the information is not visible to the client. Some features that are enabled as a result:

    1. Noting the time/date when a page was accessed
    2. Noting the url of the page that was accessed
    3. Redirecting the user to a different page after a certain action by the user (appropriate link, thank you message, end-of-submission page
    4. Alerting the user with some response (warning, hint)
    5. Identifying a user and his/her course of action on a page (counter, page-tracking)
    6. Sending a piece of information/alert/subject header that will ignite a response from the server
  • a. Authors generally use hidden control type to store information between client/server exchanges that would otherwise be lost due to the stateless nature of HTTP - for more info. go to http://www.ietf.org/rfc/rfc2616.txt)
  • b. Authors can comment the document with:

    The name of file
    The version no.
    The Date of creation
    The date of modification
    The purpose of the site
  • c. Authors can comment in between the document to explain the purpose of those steps.It can be used by Author to store information gathered from earlier form so that it can be combined with the present form’s data.

One of the main uses of hidden fields that I know of, is to store state information in the web page when a web application moves you through a series of steps, like:

    1. page 1: select products
    2. page 2: enter credit card info
    3. page 3: select shipping method, etc,

The web server isn't supposed to keep track of where you are in the process. But the server needs to know the answers that you filled in on page 1 after you complete page 3. So the web page for page 3 can be written to include your answers from page 1 as hidden fields on page 3 when page 3 is generated. This makes it easy for you to be on page 3, then hit back twice to get to page 1 and just start from there again without confusing the web server.

An example of a hidden field would be when some data should not be viewed by the visitor but is required for form processing. For example,
<input type="hidden" fname="Jane" value="Jane">
<input type="hidden" lname="Doe" value="Doe">

The hidden field another student used on here form follows:
<input type="hidden" name="recipient" value="hername@yahoo.com">
This line of code was required by her host server in order to get the mailto command to work. You can also add other hidden fields which will direct the user back to your home page after submitting the form. Ask your web host what they require to make your form function.

You can use hidden fields to embed text in a form that will be submitted along with the other data. This can be used by the server receiving the data to sort out which version of the form is sending the data and how to respond.

Do not put sensitive information in a hidden field.  Remember, hidden fields are displayed if a user views the HTML source.

This will put a subject in the subject line of your email:
<INPUT TYPE="hidden" NAME="subject" VALUE="Your Subject">
This will send the user to a thank you or confirmation page:
<INPUT TYPE="hidden"NAME="redirect"VALUE="http://www.domain.com";>

Read: http://www.swin.edu.au/corporate/webmanager/forms_tutorial/page07.htm to see how to insert a hidden field using DW.
Read: http://www.echoecho.com/htmlforms07.htm for more info on form fields.

Form Tricks

Tutorial: http://www.smartwebby.com/web_site_design/dreamweaver_form_tips.asp

Make your form element show customized fonts and/or background colors.

*New with DW MX2004: Notice Class dropdown menu in the PI for all your Form Elements:

PI textarea

You have not yet learned to create classes for Cascading Style Sheets, but for those who do (and you all will after lessons 10 and 11), you can simply select a defined class from the Class dropdown menu and apply it to any form element or the entire form. For instance I have defined a class called v12greenBG. For this class, I defined the font to Arial white 12 points, and the background to green-blue. When I assign this class to a textfield, the background of the textfield will be green-blue to the user and as the user types data, it will appear in white Arial 12 point font. Notice that the Class does not display in the Document Window. You have to preview in browser to see the Class for the Textarea.

CSS in Form Element

Here is how this textarea appears in the browser when I set the Char width to 40, the Num Lines to 6, and the Wrap to Virtual:

Class displayed in the browser

For both IE 4> and Netscape 4>. View the Source Code of my form and change the parameters I used to customize some form elements in your homework sample. Make yours with different font, different background colors, etc. Different browsers display the form's CSS styling differently. In order for the styling to work on birth IE and Netscape, we have to use two external stylesheets, one for IE and one for Netscape. In doing so, you could adapt your font sizes, or background properties, or the other styles that NN4.xx can't interpret. To do that you can use the fact that NN 4.xx does not recognize the @import. Therefore you link two style sheets:
<link rel="stylesheet" href="StyleNN.css" type="text/css"> <style type="text/css"> @import url(Style.css); /*IE and NN6x styles*/</style>
I found this info on the Macromedia site...and tested it on my form, and it works great for both IE and Netscape. There are 3 types of CSS:

    1. Inline styles
    2. Embedded or global styles
    3. Linked or external style sheets

customized form elements
Make sure to include a form action. I left mine null in the example above using the pair of quotes: ""

I inserted a style attribute in the tag for the submit button like this:
<input type="submit" id="Submit" tabindex="15" value="Submit" style="font-size: 24px; font-family: Arial;" name="Submit" />
This displayed a larger button with larger text in Dreamweaver, IE, and Netscape.
Adding this attribute to the combo box/menu list tag also worked, but only in Dreamweaver and IE.
<select name="select" tabindex="14" style="font-size: 24px; font-family: Arial;">
I tried enclosing the input button tag with <font style=“font-size: 24px”></font>
This worked to make the button and text larger in Netscape 4.7 only. Please note that CSS is still not standardized amongst all browser/OS/flavor combinations. Test on as many systems as possible to see if the CSS works.

Tips on Forms Layout:

A user should be able to tab from table cell to table cell of your form. Evaluate the layout of your form by resizing your browser window to see if you want/need to make any adjustments. Often when you make the browser window smaller you get strange layout of the names fields, checkboxes and radio button sets. If you put those in tables (even nested tables), you have more control over them when the user resizes the browser. For instance you can put the form label in one call and the form element in another to control the layout as such:

form label form element
name
checkboxes:
favorite music
rock
classical
jazz
like rap?
yes no

See how I've added tables within the form element column to have more control over the placement of the elements and the form labels to their left? This way if I resize the browser, I know that the rock label will always stay on the same row line as the checkbox for the rock option, etc.

If you don't do this, you may be surprised at how your viewers see your form. You may get last names in first name fields and improperly checked option boxes and buttons.

Always view your site with several sizes of browser windows to see how the changes affect your layout and see if you can implement more control over the layout. Please note that in the form above there is no submit or cancel button.  Also note that the user can not both like rap and not like rap.  Radio buttons are used when you only want ONE reply - either yes or no, on or off, blue OR red but NOT both, etc.

HELP!  Your Form mailto: Action doesn't work.......

Here's a success story from a previous student who set up her form to go through a cgi script provided by her new ISP and web host:

"Finally I did it (with A LOT OF HELP from my webhost)!!!!! I am so excited!!

After many trials and errors with the method of cgi-bin/script and my own e-mail method for Action, I found the method of e-mail did not work for me and I finally uploaded to my webhost's server by using first zzz.html and I could change that to index.html within their system.

I used '/cgi-bin/formmail.pl' for Action, which they gave to me. Still my e-mail as a recipient did not receive the form info. I kept sending my inquiry to them and they finally found the problem. Dreamweaver had created <form....action...enctype="multipart/form-data">. This enctype portion was messing up the data and the recipient address was not recognized by the perl script (per their explanation). They removed the portion for me. I tried my form myself and I got Thank you note with the content of my answer. It was such an exciting moment."
- Yoko Iverson

Another student found her problem in her browser of choice:

"Hi, I was having an awful time getting my "mailto" action to work. I could not send my form or submit anyone elses. So, I took the problem to the engineers where I work and learned the following:
New browsers have blocked the ability for the "mailto" action to send a form, that is why it is popping up an email window (for your default email program) or if you don't have one defined, giving you a connection failure message. It's NOT an ISP issue or an problem with your form, it's a browser issue.

What I did to get my form to submit (and those of classmates who are using "mailto") was:
1. Downloaded and installed Netscape 4.8 (I think it's 4.7) for Mac.
2. Configured my ingoing and outgoing mail server under preferences (This will not work unless attached to an email program)
3. Loaded and submitted my form & several others. IT WORKED!!!
Hope that this helps someone...Jann"

NOTE: Before you post a question about forms or the mailto: action in the form, please search the FORUMS with the keyword "FORMS" and include archived posts.

You are not required to use a form validation behavior for this homework.  Behaviors are taught in another lesson later in the course. However - please use the forms validation behavior on your final website. In addition, when you collect data, you want to make sure that you name your form elements descriptively so that you know what you mean when you get back a YES or NO reply, or some text returned to you by the server.

For example, this is what I received when I clicked on a previous student's submit button without filling out required fields. This is meaningless to both the user and to the author - and/or those processing the data. Name all of your labels and elements descriptively. For instance in the form reflected by the alert box below, textfield was firstname, textfield2 was lastname, textfield3 was email, etc.

script alert for form data errors

 

Validate Forms

  1. The first step is to insert a form by clicking on Insert > Form
  2. The next step is to insert 3 text boxes for name, email and phone. Choose Insert > Form Objects > Text Field to insert 3 text boxes. Name the first text box 'Name', the second 'Email' and the third 'Phone' in the Properties inspector.
  3. Insert a submit button by clicking on Insert > Form Objects > Button
  4. Open the behaviors window by choosing Window > Behaviors. Select the form tag and click on the '+' icon in the behaviors window. Choose Validate Form
  5. In the pop-up window that appears choose the text field you want to validate and select the required validation.
    • Select Required for Name
    • Select Email for Email Address
    • Select Number for Phone
  6. Click on OK.
  7. Check the validation clicking on File > Preview in Browser

Copyright © 2008 - 2009 Robert D. Cormia - October 29, 2008