Xem mẫu

The page containing this form appears in Figure 10.20. Output Figure 10.20. A form that uses Cascading Style Sheets. file:///G|/1/0672328860/ch10lev1sec6.html (6 von 7) [19.12.2006 13:49:19] file:///G|/1/0672328860/ch10lev1sec6.html (7 von 7) [19.12.2006 13:49:19] Planning Your Forms Before you start creating complex forms for your web pages, you should do some planning that will save you time and trouble in the long run. First, decide what information you need to collect. That might sound obvious, but you need to think about this before you start worrying about the mechanics of creating the form. Next, review this information and match each item with a type of form control. Ask yourself which type of control is most suited to the type of questions you`re asking. If you need a yes or no answer, radio buttons or check boxes work great, but the textarea element is overkill. Try to make life easier for the users by making the type of control fit the question. This way, analyzing the information using a script, if necessary, will be much easier. You also need to coordinate with the person writing the CGI script to match variables in the script with the names you`re assigning to each control. There isn`t much point in naming every control before collaborating with the script authorafter all, you`ll need all the names to match. You also can create lookup tables that contain expansive descriptions and allowable values of each form control. Finally, you might want to consider validating form input through scripting. Using JavaScript, you can embed small programs in your web pages. One common use for JavaScript is writing programs that verify a user`s input is correct before she submits a form. I`ll discuss JavaScript in more detail in Lesson 12, "Introducing JavaScript." file:///G|/1/0672328860/ch10lev1sec7.html [19.12.2006 13:49:20] Summary As you can see, the wonderful world of forms is full of different types of form controls for your visitors. This truly is a way to make your web pages interactive. Be cautious, however. Web surfers who are constantly bombarded with forms are likely to get tired of all that typing and move on to another site. You need to give them a reason for playing! Table 10.1 summarizes the HTML tags used today. Remember these points and you can`t go wrong: Table 10.1. Today`s HTML Tags Tag
action enctype method type text password submit reset checkbox radio image button hidden file Use Creates an HTML form. You can have multiple forms within a document, but you cannot nest the forms. An attribute of that indicates the server-side script (with a URL path) that processes the form data. An attribute of the tag that specifies how form data is encoded before being sent to the server. An attribute of that defines how the form data is sent to the server. Possible values are get and post. A element that creates controls for user input. An attribute of that indicates the type of form control. Possible values are shown in the following list: Creates a single-line text entry field. Creates a single-line text entry field that masks user input. Creates a Submit button that sends the form data to a server-side script. Creates a Reset button that resets all form controls to their initial values. Creates a check box. Creates a radio button. Creates a button from an image. Creates a pushbutton. The three types are Submit, Reset, and Push, with no default. Creates a hidden form control that cannot be seen by the user. Creates a file upload control that enables users to select a file with the form data to upload to the server. file:///G|/1/0672328860/ch10lev1sec8.html (1 von 2) [19.12.2006 13:49:20]