martin2k

The INPUT Tag

HomeForumTutorials Tags:
 
 

Name

Form Input

Description

Defines elements of a FORM, which are either hidden or can be completed by the user.  Types of elements that can be defined include button, checkbox, file, hidden, image, password box, radio button, reset button, submit button and a text box.  See also FORM, SELECT and TEXTAREA.

Attributes

ALIGN

Only used if type is set to 'image'.

Specifies the alignment.  The possible values are:

Value
absbottom
absmiddle
baseline
bottom
left
middle
right
texttop
top

ALT

Only used if type is set to 'image'.

This tag shows a description of the image if the user has disabled images in their browser or if the image was not found.  In Internet Explorer, this text is shown when the mouse if hovered over the image.

CHECKED

If the type is set to 'checkbox' or 'radio', it will be checked.

DISABLED

Disables the element.

MAXLENGTH

Only used if type is set to 'text'.

Defines the maximum length of a textbox or password box.

NAME

Specifies the name for the element so that it can be identified by a form.  All Radio buttons that you want to be in the same group, must have the same name.

READONLY

Only used if type is set to 'text'.

If set, the user will not be able to edit the textbox.

SRC

Only used if type is set to 'image'.

Specifies the image's URL.  To show to an image on the same site use the local path e.g. src="button.gif" or src="folder/photo1.jpg".  You can also use dots to link to an image in the parent folder e.g. src="..\diagram.png".  To show a picture from another site, use the full URL e.g. src="http://www.martin2k.co.uk/tgflogo.gif".

TYPE

Type Meaning
button A button
checkbox A checkbox
file Creates a textbox and a browse button.  It is used to browse for a file, which then goes into the textbox.
hidden A hidden field.  E.g. in some forms you can specify that the IP address of the user is sent along with the other fields.
image An image button
password A textbox, where the characters are replaced by symbols (such as an asterisk) to hide what is entered.
radio A radio button.  Only one radio button in a group can be selected.
reset A button, used to reset the contents of a form
submit A button, used to submit the contents of a form
text A text box

VALUE

Specifies the value of the element.  For the three button types, this defines the caption.  For checkboxes and radio buttons, it defines the text that is passed to the script.  For hidden, text and password elements, it defines the initial value.

Related Tags

The INPUT tag used within the FORM tag.

Example

Code

<input type="button" name="B1" value="A button">

<input type="checkbox" name="C1" value="Checkbox">Checkbox text

<input type="file" name="F1">

<input type="password" name="P1" value="password">

<input type="radio" name="CB1" value="Left radio button" checked>Left radio button <input type="radio" name="CB1" value="Right radio button">Right radio button

<input type="text" name="T1" value="textbox text">

A hidden element used by the FormMail script.

<input type="hidden" name="env_report" value="HTTP_USER_AGENT,REMOTE_ADDR">

Generates

Checkbox text

Left radio button Right radio button

 


Please fill in the below form if you have any comments or additional information you want to add about the above information.  If you have any questions, please visit the ForumAny questions sent using this form will be ignored.

* - Mandatory

*Name: E-mail:

*Comments:

*Please type the following code (your comment cannot be accepted without it):


© Martin Allen 1999 - 2006.  Last updated Thursday 26 October 2006 09:36:18 PM +0100.