|
The INPUT element is the most used element
in a Form. Using this element it is possible to build a Form
using no other elements due to the variety of widgets available through the type attribute.
Syntax:
<INPUT [type =text | Password | checkbox | radio | submit | image | button | hidden | file]
[name = controlname]
[value = controlvalue]
[checked]
[disabled]
[readonly]
[size=controlwidth]
[maxlength = wordlength]
[src=URL]
[alt=alttext]
[usemap=URL]
[align=left|center|right|justify]
[tabindex=tabnum]
[accesskey=keycombo][onfocus=script][onblur=script][onselect=script]
[onchange=script]
[accept=charset] [core]
[international]
[events]>
|
|
The Button Value |
|
|
The Reset Value |
|
|
The Submit Value |
|
|
The Image Value |
|
|
The Checkbox Value |
|
|
The Radio Value |
|
|
The Hidden Value |
|
|
The Text Value |
|
|
The Password Value |
|
|
Other Attributes |
Apart from submit and reset buttons that
were available with earlier versions, HTML 4.0 allows us to
define buttons using the INPUT element. The Button INPUT type
has no default function; you define its function using a script.
Example:
<INPUT type = "button"
name = "custom_button_01"
value = "push this"
onclick = "runprocess ()">
Note:
|
|
Name is the variable name given to the INPUT element of type Button. |
|
|
Value is the text that appears on the Button. |
|
|
Onclick specifies the function to be called when clicked on the button. |
The Reset value for the type attribute creates
a button with only one purpose: all Form entries are cleared
to their default entries or left blank if no default is specified.
Example:
<INPUT type="reset"
name = "reset"
value = "Reset Form">
Note:
|
|
Type specifies that the input element type is a reset button. |
|
|
Value provides the text to be displayed on the reset button. |
The Submit value of the type attribute creates
a button that like the reset button has a single purpose.
This button is used to send the name/value pairs of the active
Form elements to the URL specified in the FORM declaration.
The HTML specification enables multiple submit buttons to exist.
Example for using single submit button:
<INPUT type ="submit"
name = "Submit"
value = "Submit Form">
Example for using multiple submit buttons:
<FORM ACTION = "form-processor">
your name: <INPUT NAME = "name">
<P> I have read the license and agree to abide by it. </P>
<INPUT TYPE= "SUBMIT" VALUE= "I Agree" NAME= "Choice">
<INPUT TYPE= "SUBMIT" VALUE= "I disagree" NAME= "Choice">
An INPUT element with TYPE = "IMAGE"
creates an image button. An image button is similar in function
to a submit button except that instead of a gray button with
text, an image of your choice is displayed.
Example:
<INPUT type = "image"
src ="submit_image.gif">
Note: src
specifies the path and the name of the image. The attributes
for an image button are similar to the attributes of the <IMG> tag.
The Checkbox value of the type attribute
is a boolean input device; it's either off or on. It looks
like a hollow box that when selected is filled with a check
mark to indicate its active state. If the user wants to make
multiple selections on the same topic, you can use several
check box elements with the same name and different value.
Syntax:
<INPUT type= "checkbox" name= "controlname"
value= "controlvalue" [checked]>
Example:
<H3>pick your toppings:</H3>
<INPUT type = "checkbox" name= "topping"
value = "cheese" checked>Cheese<BR>
<INPUT type = "checkbox" name= "topping"
value = "pepperoni">Pepperoni<BR>
<INPUT type = "checkbox" name= "topping"
value = " Shrooms">Mushrooms<BR>
<INPUT type = "checkbox" name= "topping"
value = "clams">Smoked clams<BR>
Each checkbox that is switched on will submit
a name / value pair with the same field name.
The Radio value of the type attribute is
very similar to the checkbox type. The difference between
the two is that radio buttons are mutually exclusive i.e.
selecting one, turns off the other. The default choice is
indicated using a CHECKED attribute.
Syntax:
<INPUT type= "radio" name= "controlname" value= "controlvalue" [checked]>
Example:
<H3>pick the crust</H3>
<INPUT type= "radio" name = " crust"
value= "deep dish" checked>Deep Dish<BR>
<INPUT type= "radio" name = " crust"
value= "hand tossed">Hand Tossed<BR>
<INPUT type= "radio" name = " crust"
value= "whole wheat">Whole Wheat<BR>
Copyrights : Layout Galaxy All Rights Reserved
No part of this tutorial may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, electrostatic, magnetic tape, mechanical or otherwise, without prior permission in writing from Layout Galaxy.
|
|