Current course:
Forms add interactivity to your site and are made up of text boxes, check boxes, radio buttons, drop-down lists, and other input fields.

Form tags can be placed anywhere in the BODY of your html doc:




Even if you just want to substitute a text or image link with a type of Form input, you will still need to use the form tags. In other words, all input tags, select tags, and textarea tags must be contained within a FORM tag.

INPUT tags are the primary tag used in FORMs. The input tag allows your readers to input data to your Web server.

There are eleven specific types of elements that can be used in forms:

1. button
2. checkbox
3. image
4. radio
5. select
6. text
7. reset
8. submit
9. file
10. hidden
11. password

You choose which type of input tag you would like by placing it in the type=" " attribute.

<input type="button" value="my button" name="thebutton" />
The button input type allows you to create custom input buttons. It is most commonly used with JavaScript forms with the onClick attribute so that data is not sent to the Web server until the JavaScript has processed it.

<input type="checkbox" name="choices" value="choice1"/>
<input type="checkbox" name="choices" value="choice2"/>

With a checkbox element, you can give your readers a list of items to choose from. They can choose more than one in the list. If you have a group of checkboxes, link them all together by giving them the same name. The values will all be sent to the form separately.

Choice 1 Choice 2

<input type="image" name="my_image" src="images/pixel.jpg" width="100" height="50" border="0" />

With the image input type, you can create images for your button using forms. One thing to note, images as submit buttons don't allow for the tab key to move the focus to it, and this makes them less accessible for people with no mouse.

<input name="myRadio" type="radio" value="lettuce" />
Radio buttons give readers a "one of many" choice combination. Like the checkbox input type, radio button groupings all have the same NAME, and each value is different. If a reader chooses one value, all the other values will be deselected.


<select name="choices">
<option value="0"></option>
<option value="1">First Choice</option>
<option value="2">Second Choice</option>
Pull down menus allow users to choose one of many options. Like the radio button input type, select menus groupings all have the same NAME, and each value is different.

<input name="myText" type="text" size="20" maxlength="20">enter text
The text box is the most common input type and to make HTML easier, is the default for the INPUT tag. This input element allows your readers to type in any text information into the box.

<textarea name="myTextArea" cols="20" rows="6">enter text</textarea>

The textarea box allows you set a larger box for the text input.

single line


<input type="reset" name="myReset">
The reset button resets the form to its default value. With most forms, this is blank entries, but if the fields have starting values, the reset button will return the form to that. This "resetting" is done by the browser, not the server. This button will have the default value of "Reset", if you want it to say something different, change the VALUE="" attribute.

<input type="submit" name="mySubmit">
In order for a form to be sent to the server it needs some form of submit button. This field sends the form information to the Web server when it is clicked. In Internet Explorer it has a default value of "Submit". If you want to change this, change the VALUE="" attribute.

<input type="file" />
The file input type allows your readers to upload a file to your Web server. This typically needs to be processed with some Javascript, PHP or other web programming language.

<input type="hidden" />
Hidden fields are used to "save state" within an HTML form. They are most often used in forms that have multiple pages and information that needs to be carried from one page to the next. They are not shown on the Web page, but the information is sent along with other form input fields.

<input type="password" name="myPassword" value="enter password"/>
The password field looks almost identical to the text field. However, when you type in it, the letters are hidden. This allows you to have a little more security for passwords on your forms. Remember, however, that the passwords are not sent encrypted in any way. So don't rely on this to secure truly important secret information.

enter password