Forms are a great way to gather information from clients, and put it to use. Forms are used to search the internet, buy stuff online, and fill in guestbooks. You can do just about anything with a form, provided you know how to make it work.
The beginning and ending <form> tag is what makes this possible. <Form> has three required attributes: enctype, action, and method. Enctype stands for "encryption type." This attribute is especially useful if you are ordering something with a credit card; the number can't be easily stolen by hackers. The simplest value of enctype is "text/plain", indicating that there will be no encryption. The action attribute can be set to a mailto address as in the links, which will e-mail the entries on the form to the address specified. A more useful way to process forms is by setting the action attribute to the address of a cgiscript for use on the site instantly. CGI stands for Common Gateway Interface. We can't teach you how to make them, but they can be found for many different purposes at these sites:
For both the mailto and the cgi script, the method attribute should be set to "post", indicating that the raw information from the form should be sent to that target. A final form tag set looks like this: <form enctype="text/plain" action="http://www.angilfire.com/mn3/bpa/cgi-bin/CGI.cgi" method="post"></form>.
2. Text Controls
Control is the general term for the field or box in a form into which information is entered. This subsection will examine the 3 types of controls into which text is entered as a value. These are the text box, password box, and text area controls.
The text box control is used to enter short segments of text, like a user name. It is created using the <input> tag. This tag has three attributes which can be used for all of its applications, and two more which relate specifically to its use for text box and password box controls. The type attribute identifies the function of the <input> tag. Because there are a number of different uses for the tag, the type attribute is very important in defining the control. The type setting for a text box is "text". The name attribute is used to identify the control among the others in your form. It doesn't add a name next to the box on the screen; you still need to type in your own. A value attribute can be added to add an initial value to the control. At the time of loading this value will be displayed in the text box, and can be deleted by the client. The default value is having none. Two other useful attributes are size and maxlength. Size sets the number of characters in length the text box appears on the screen, and maxlength sets the maximum number of characters that can be entered into the box. Please note that while <form> tags need corresponding endings, but <input> tags don't. The text box control looks like this: If you had a cow, what would you name her? <input type="text" name="name" value="Elsie" size="15" maxlength="20">
The password box control differs only slightly from the text box. The main difference is that as the information is entered, it shows up in asteriks or bullets, not text. The only differences in coding are that the value of the type attribute is changed from "text" to "password", and you need a different name: What is your favorite number (of cows)? <input type="password" name="cowcard" value="5" size="15" maxlength="24">
The text area control uses its own unique tag, which requires a beginning and ending. The <textarea> tag creates a large box for entering up to 32,700 characters of text. It does not have a type attribute, because there is only one use for the <textarea> tag. The value attribute is also gone, replaced by the ability to put text between the beginning and ending <textarea> tags. In addition to the standard name attribute, there are also a number of other attributes which address the unique issues surrounding a text area. The rows and cols attributes are given numerical values to designate the width in characters of the rows and columns available to type in. This does not limit the amount that can be written, because a scroll bar automatically appears when it goes over the last row. The wrap attribute makes the text automatically move to the next line when the user types beyond the limit of the control as defined by the cols attribute. Wrap doesn't need an actual value to work. <textarea name="industries" cols="50" rows="5" wrap="">Cows, of course!</textarea>