The type
property get the type of a drop-down list.
type |
Yes | Yes | Yes | Yes | Yes |
var v = selectObject.type
A String type value representing the type of form element the drop-down list (<select> element) is.
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:
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: