contents.gifindex.gifprev1.gifnext1.gif

pueblo00000000.gif <input> element

The Input element represents a field whose contents may be edited by the user. This tag takes a variety of attributes which define the name of the field, what type of input it is, the maximum length (in the case of text) or a restricted range of values (in the case of radio or checkbox buttons).

Attributes

CHECKED

Indicates that a checkbox or radio button is selected. Unselected checkboxes and radio buttons do not return name/value pairs when the form is submitted.

MAXLENGTH

Indicates the maximum number of characters that can be entered into a text field. This can be greater than specified by the SIZE attribute, in which case the field will scroll appropriately. The default number of characters is unlimited.

NAME

Symbolic name used when transferring the form's contents. The NAME attribute is required for most input types and is normally used to provide a unique identifier for a field, or for a logically related group of fields.

SIZE

Specifies the size or precision of the field according to its type. For example, to specify a field with a visible width of 20 characters:

<input type=text size="24">

TYPE

Defines the type of data the field accepts. Defaults to free text. Several types of fields can be defined with the type attribute:

checkbox Used for simple Boolean attributes, or for attributes that can take multiple values at the same time. The latter is represented by a number of checkbox fields each of which has the same name. Each selected checkbox generates a separate name/value pair in the submitted data, even if this results in duplicate names. The default value for checkboxes is "on".

hidden No field is presented to the user, but the content of the field is sent with the submitted form. This value may be used to transmit state information about client/server interaction.

image This type is not currently supported by Web Tracker.

password The same as the text type, except that text is not displayed as it is entered.

radio Used for attributes that accept a single value from a set of alternatives. Each radio button field in the group should be given the same name. Only the selected radio button in the group generates a name/value pair in the submitted data. Radio buttons require an explicit VALUE attribute.

reset A button that when pressed resets the form's fields to their specified initial values. The label to be displayed on the button may be specified just as for the submit type button.

submit A button that when pressed submits the form. You can use the VALUE attribute to provide a non-editable label to be displayed on the button. The default label is application-specific. If a submit button is pressed in order to submit the form, and that button has a NAME attribute specified, then that button contributes a name/value pair to the submitted data. Otherwise, a submit button makes no contribution to the submitted data.

text Used for a single line text entry fields. Use in conjunction with the SIZE and MAXLENGTH attributes. Use the <textarea> element for text fields which can accept multiple lines.

VALUE

The initial displayed value of the field, if it displays a textual or numerical value; or the value to be returned when the field is selected, if it displays a Boolean value. This attribute is required for radio buttons.

ALIGN
SRC

These attributes are not currently supported by Web Tracker.

Examples

The following example defines a form:

<form method=post action="http://www.chaco.com/htbin-post/myscript">

<p>Please answer the following questions:

<ol>

<li>Name: <input type=text size=40 name=Name>

<li>How did you hear about our product? (check all that apply):<br>

<input type=checkbox name=Source value=Newspaper>Newspaper

<input type=checkbox name=Source value=Radio>Radio

<input type=checkbox name=Source value=TV>TV

<input type=checkbox name=Source value=Person>Friend/colleague

<li>How many would you like to order? <input type="number" name="Quantity" size=4 value=1>

<input type=radio name=CC value=Visa checked>Visa

<input type=radio name=CC value=Mastercard>Mastercard

<li>Number: <input type=number name=CCNum size=16>

and expiration date (mm/yy): <input type=text name=Expiration size=5>

</ol>

<input type=submit value=" Send this form ">

<input type=reset value=" Reset all values and start over ">

</p>

</form>

Also see

<form>

<option>

<select>

<textarea>