Click Here!
home account info subscribe login search My ITKnowledge FAQ/help site map contact us


 
Brief Full
 Advanced
      Search
 Search Tips
To access the contents, click the chapter and section titles.

Platinum Edition Using HTML 4, XML, and Java 1.2
(Publisher: Macmillan Computer Publishing)
Author(s): Eric Ladd
ISBN: 078971759x
Publication Date: 11/01/98

Bookmark It

Search this book:
 
Previous Table of Contents Next


Because HTTP is a stateless protocol (information from the user’s session is not tracked), it is not possible for the input from one form to be carried forward to another. Thus, another application of hidden fields is doing just that. This enables you to split up a long form into several smaller forms and still keep all the user’s input in one place by passing it from one form to the next in the sequence. Suppose, for example, that in the first of a sequence of several forms, you collect a visitor’s name and mailing address. That information is passed to the script that processes the form. Because part of what this script has to do is build the next form in the sequence, it would be an easy matter to have the script include in the next form hidden fields that carry the name and address information forward.


NOTE:  Because hidden fields are transparent to users, it doesn’t matter where you put them in your HTML code. Just make sure they occur between the <FORM> and </FORM> tags that define the form that contains the hidden fields.

Hidden fields are integral in the development of ColdFusion and Active Server Page applications. Look for examples of hidden field usage as you read Chapter 33, “Active Server Pages and VBScript,” and Chapter 34, “Using ColdFusion.”

Files You can upload an entire file to a server by using a form. The first step is to include the ENCTYPE attribute in the <FORM> tag. To enter a filename in a field, the user needs the <INPUT> tag with TYPE set equal to FILE:

<FORM ACTION=”upload.cgi” ENCTYPE=”application/x-www-form-urlencoded”>
What file would you like to submit: <INPUT TYPE=”FILE” NAME=”upload_file”>
...
</FORM>

Being able to send an entire file is useful when submitting a document produced by another program—for example, an Excel spreadsheet, a résumé in Word format, or a compiled executable file.


NOTE:  You can also use the ACCEPT attribute when you have an <INPUT> field of type FILE to specify the MIME types of files that are acceptable for upload.


NOTE:  File upload fields are usually accompanied by a Browse button that enables users to browse to the file that they want to upload. The Browse button is supplied by the browser, and you don’t need to do anything special to place the button there.


CAUTION:  

Depending on the user’s browser version and operating system, it’s possible for the name of the file that gets copied to the Web server to not match the name of the source file. That is, a user could submit budget.xls from her machine and the file copied onto the server might have some other name. Be sure to test your applications that use file upload fields to verify that the naming stays consistent.


Multiple Line Text Windows

Text and password boxes are used for simple, one-line input fields. You can create multiline text windows that function in much the same way by using the <TEXTAREA> and </TEXTAREA> container tags. The HTML syntax for a text window is as follows:

<TEXTAREA NAME=”Name” [ROWS=”rows”] [COLS=”columns”]>
Default_window_text
</TEXTAREA>

The NAME attribute gives the text window a unique identifier, the same as it does with the variations on the <INPUT> tag. The optional ROWS and COLS attributes enable you to specify the dimensions of the text window as it appears on the browser screen. The default number of rows and columns varies by browser.

The text that appears between the <TEXTAREA> and </TEXTAREA> tags shows up in the input window by default. To type in something else, users need to delete the default text and enter their text.

Multiline text windows are ideal for entry of long pieces of text, such as feedback comments or email messages (see the Concert Feedback page in Figure 8.4 and corresponding code in Listing 8.4). Some corporate sites on the Web that collect information on potential employees might ask you to copy and paste your entire résumé into multiline text windows!


FIGURE 8.4  A multiline text window is ideal for gathering free-response text, such as comments or feedback.

Listing 8.4 HTML Code to Produce a Multiline Text Window


<tr valign=”top”>
<td colspan=2>Comments<br>
<textarea name=”comments” cols=”40" rows=”10"></textarea>
</td>
</tr>

A useful attribute of the <TEXTAREA> tag that is supported by Netscape Navigator 4 and Internet Explorer 4 is WRAP. WRAP is a Boolean attribute that, when present, instructs the browser to wrap text within the input window rather than to let it scroll horizontally. Users will appreciate your use of this attribute because it spares them from having to remember to press the Enter key each time they want to move to a new line in the text window.

Menus

The final technique for creating a named input field is to use the <SELECT> and </SELECT> container tags to produce pull-down or scrollable option menus (see Figure 8.5 and Listing 8.5). The HTML code used to create a general menu is as follows:

<FORM ...>
<SELECT NAME=”Name” [SIZE=”size”] [MULTIPLE]>
<OPTION [SELECTED]>Option 1</OPTION>
<OPTION [SELECTED]>Option 2</OPTION>
<OPTION [SELECTED]>Option 3</OPTION>
...
<OPTION [SELECTED]>Option n</OPTION>
</SELECT>
....
</FORM>

In the <SELECT> tag, the NAME attribute again gives the input field a unique identifier. The optional SIZE attribute enables you to specify how many options should be displayed when the menu renders on the browser screen. If you have more options than you have space to display them, you can access them either by using a pull-down window or by scrolling through the window with scroll bars. The default SIZE is 1. If you want to let users choose more than one menu option, include the MULTIPLE attribute. When MULTIPLE is specified, users can choose multiple options by holding down the Ctrl key and clicking the options they want.


NOTE:  If you specify the MULTIPLE attribute and SIZE=1, a one-line scrollable list box displays instead of a drop-down list box. This box appears because you can select only one item (not multiple items) in a drop-down list box.


FIGURE 8.5  Job seekers on www.careerbuilder.com can choose their geographic area and their field of expertise from menus created with the <SELECT> tag.


Previous Table of Contents Next


Products |  Contact Us |  About Us |  Privacy  |  Ad Info  |  Home

Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc.
All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement.