Examples of FORM Tag

Example #1: Different TYPE Attributes of INPUT Tag

INPUT TypeHTML CodeResult
hidden <INPUT TYPE="hidden">
checkbox <INPUT TYPE="checkbox">
radio <INPUT TYPE="radio">
text <INPUT TYPE="text">
password <INPUT TYPE="password">
submit <INPUT TYPE="submit">
reset <INPUT TYPE="reset">
file <INPUT TYPE="file">
image <INPUT TYPE="image"> there will be an images here

Example #2: Above Example with Some Additional Attributes of INPUT Tag

INPUT Tpye Example HTML CodeResult
hidden <INPUT TYPE="hidden" NAME=hidden#1 VALUE=5>
checkbox <INPUT TYPE="checkbox" NAME="spanish" VALUE="yes">Spanish Spanish
radio <INPUT TYPE="radio" VALUE="Apple" NAME="favorite_fruit">Apple Apple
text <INPUT TYPE="text" VALUE="Type your name here" NAME="visitor_name" SIZE="20" MAXLENGTH="35">
password <INPUT TYPE="password" NAME="keepitsecret">
submit <INPUT TYPE="submit" VALUE="Click Here to Submit">
reset <INPUT TYPE="reset" VALUE="Click Here to Reset">
file <INPUT TYPE="file" NAME="http://www.nowhere.com/somefile.txt">
image <INPUT TYPE="image" SRC="images/submit_it.gif" NAME="submit_image" ALIGN="top" HEIGHT="25" WIDTH="150">
 

Example #3: Use of Several radio Buttons

When the NAME attribute is the same for several radio buttons, only one of them is selectable at a time. So, if you need to use several groups of different radio button in a form, the group names should be different but within a group NAME should be the same for all radio buttons.

Select your favorite fruit.
Apple
Orange
Banana

Select your favorite color.
Red
Green
Blue

The above form was generated by the following INPUT statements:

Select your favorite fruit.<br>
<INPUT TYPE="radio" VALUE="Apple" NAME="favorite_fruit">Apple<br>
<INPUT TYPE="radio" VALUE="Orange" NAME="favorite_fruit">Orange<br>
<INPUT TYPE="radio" VALUE="Banana" NAME="favorite_fruit" CHECKED> Banana

<p>Select your favorite color.<br>
<INPUT TYPE="radio" VALUE="Red" NAME="favorite_color">Red<br>
<INPUT TYPE="radio" VALUE="Green" NAME="favorite_color" CHECKED> Green<br>
<INPUT TYPE="radio" VALUE="Blue" NAME="favorite_color">Blue</p>

 

Example #4: Use of TEXTAREA

Please explain the complains that you have about Dr. Salimian's classes in details.

 
The above form was generated by the following statements:

<TEXTAREA NAME="salimian_complaint" ROWS="10" COLS="40">
Besides having us to do tons of
homework and not returning it us, he
needs to check his eyesight because he
sees something in us that we have hard
time to see ourselves. I also have the
following complaints::
</TEXTAREA>
 

 

Example #5: Use of SELECT

Your favorite fruit?

The first menu in the above form was generated by the following statements:

<SELECT NAME="favorite_fruit_list" SIZE=5 MULTIPLE>
<OPTION VALUE="Apple">Apple
<OPTION VALUE="Orange">Orange
<OPTION VALUE="Kiwi">Kiwi
<OPTION VALUE="Grape">Grape
<OPTION SELECTED VALUE="Banana">Banana
</SELECT>

The second menu was generated by the changing the SIZE=5 attribute to SIZE=2 in the above statements.

The third menu was generated by the removing SIZE=5 and MULTIPLE attributes from the first OPTION statement in the above statements.

The forth menu was generated by the removing SIZE=5 and MULTIPLE attributes from the first OPTION statement and SELECTED from the last OPTION statement in the above statements.