The HTML form element defines input elements that let the user interact with the page by entering data, choosing an item from a list, or clicking a button. For example, let's suppose a user must log on to a secured site. The solution is an HTML form, which in this case might be a couple of input elements-one for the user's name, and a second for the password. The page presents an input element in which the user enters their name and password. When done, the user probably clicks a button to submit their logon information to the server for processing and acceptance or rejection.
The form element works with the input elements, which tell the page what to display and then how to store any user responses. The form tag has the following syntax:
<form name="formname" action=" URL" method="post|get" target=" destinationframe">
The name parameter identifies the form, action is the URL where you want to send the data for processing, method specifies post or get, and target is the frame where you want the response to appear (if you're using frames). For example, the following <form> tag sends the data in the form named frmLogIn to a page named LogIn.asp using the post method:
<form name="frmLogIn" action="LogIn.asp" method="post">
Although all four parameters are optional, always name the form so that you can manipulate it (and the input elements) using client-side script. The action parameter specifies a new URL (page). If you omit this parameter, the form defaults to the current page. The method parameter accepts one of two predefined constants: post and get. We'll discuss these in detail later in the chapter, but in brief, the post method sends data in a single line. In contrast, get combines the form data and then appends it to the URL. For the most part, you'll use post, but the default method is get. When working with frames, the target parameter specifies the frame you want to display. If there is no frame, the browser opens a new (frame) window. The target parameter is optional and necessary only when the page uses frames or when you want a link to open a specific window. Don't worry if that last bit confuses you-you won't be working with frames or anything that complicated in this chapter. We just want you to be aware that the option exists.
Forms are an HTML element, but keep in mind that pure HTML is static. Scripting languages bring forms to life. Throughout the rest of the chapter, you'll see form and input elements mingled with Active Server Pages (ASP), a Microsoft server technology and scripting language. (In this chapter, we'll look at just the scripting language.) We chose ASP because of its universal popularity, but ASP is not the only option for forms processing. ASP can use many scripting languages. We chose to use VBScript with ASP because it's easy to learn, easy to use, and supported in Dreamweaver MX.
For an in-depth look at ASP, see Chapter 13.