|
To access the contents, click the chapter and section titles.
Platinum Edition Using HTML 4, XML, and Java 1.2
Because HTTP is a stateless protocol (information from the users 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 users 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 visitors 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.
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 programfor example, an Excel spreadsheet, a résumé in Word format, or a compiled executable file.
Multiple Line Text WindowsText 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!
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. MenusThe 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.
|
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. |