You are here: Reference > JavaScript > client-side > HTML DOM > properties > type (keygen, select)

type property (keygen, select)

Browser support:
Returns a string that identifies whether more than one item can be selected in a selection list.
The selection type can be modified by the multiple property.

Syntax:

object.type;
You can find the related objects in the Supported by objects section below.
This property is read-only.

Possible values:

String that represents the type of the selection list.
One of the following values:
select-one
Multiple selection is disabled. The multiple property is set to false.
select-multiple
Multiple selection is enabled. The multiple property is set to true.
Default: this property has no default value.

Example HTML code 1:

This example illustrates the use of the type property:
<head>
    <script type="text/javascript">
        function GetSelType () {
            var selectObj = document.getElementById ("mySelect");
            alert (selectObj.type);
        }

        function ToggleSelType () {
            var selectObj = document.getElementById ("mySelect");
            selectObj.multiple = !selectObj.multiple;
        }
    </script>
</head>
<body>
    <select multiple="multiple" id="mySelect">
        <option>Apple</option>
        <option selected="selected">Peach</option>
        <option>Pear</option>
    </select>

    <br />
    <button onclick="GetSelType ();">Get the selection type!</button>
    <br />
    <button onclick="ToggleSelType ();">Toggle the selection type!</button>
</body>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content