type property (input)
Sets or retrieves the type of the input element.
Syntax:
You can find the related objects in the Supported by objects section below.
This property is read/write.
HTML page for this property: type |
Possible values:
String that sets or retrieves the type of the input element.
One of the following values:
The element is a button control. See the input:button element for details. | |||||||
The element is a check box control. See the input:checkbox element for details. | |||||||
The element is a file selector object with a single-line text input control and a browse button. See the input:file element for details. | |||||||
The element is a hidden text control. See the input:hidden element for details. | |||||||
The element is an image control. See the input:image element for details. | |||||||
The element is a single-line text input control, except that text is rendered in such a way as to hide the characters. See the input:password element for details. | |||||||
The element is a radio button control. See the input:radio element for details. | |||||||
The element is a slider control. See the input:range element for details. | |||||||
The element is a reset button. Clicking on a reset button resets all controls in the form to their initial values. See the input:reset element for details. | |||||||
The element is a single-line text input control with a search history dropdown list. See the input:search element for details. | |||||||
The element is a submit button. Clicking on a submit button sends the named contents of the form. See the input:submit element for details. | |||||||
Default. The element is a single-line text input control. See the input:text element for details. |
Default: text.
Example HTML code 1:
This example illustrates the use of the type attribute:
|
||||
<input type="text" name="firstname" /><br /> <input type="radio" /><br /> <input type="checkbox" /> |
||||
|
||||
Did you find this example helpful?
|
Example HTML code 2:
This example illustrates the use of the type property:
|
||||
<head> <script type="text/javascript"> function GetInputType () { var inputs = document.getElementsByTagName ("input"); for (var i = 0; i < inputs.length; i++) { alert ("The " + i + ". input type = " + inputs[i].type); } } </script> </head> <body> <input type="text" name="firstname" /><br /> <input type="radio" /><br /> <input type="checkbox" /> <br /> <button onclick="GetInputType ();">Get input type!</button> </body> |
||||
|
||||
Did you find this example helpful?
|
Supported by objects:
HTML elements:
External links:
User Contributed Comments