Javascript Reference - HTML DOM Select type Property








The type property get the type of a drop-down list.

Browser Support

type Yes Yes Yes Yes Yes

Syntax

var v = selectObject.type 

Return Value

A String type value representing the type of form element the drop-down list (<select> element) is.





Example

The following code shows how to get the type of a drop-down list that allows multiple selections.


<!DOCTYPE html>
<html>
<body>
<!-- ww  w. j  a  v a2  s . c o  m-->
<form>
<select id="mySelect" multiple>
  <option>A</option>
  <option>B</option>
  <option>C</option>
  <option>D</option>
</select>
</form>
<button onclick="myFunction()">test</button>
<p id="demo"></p>

<script>
function myFunction() {
    var x = document.getElementById("mySelect").type;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

The code above is rendered as follows:





Example 2

The following code shows how to get the type of a drop-down list.


<!DOCTYPE html>
<html>
<body>
<!--from   www  . ja  v a  2s. c o  m-->
<form>
<select id="mySelect">
  <option>A</option>
  <option>C</option>
  <option>C</option>
  <option>D</option>
</select>
</form>
<button onclick="myFunction()">test</button>

<p id="demo"></p>

<script>
function myFunction() {
    var x = document.getElementById("mySelect").type;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

The code above is rendered as follows: