The multiple
property sets or gets
if the select support multiple selections.
multiple |
Yes | Yes | Yes | Yes | Yes |
Return the multiple property.
var v = selectObject.multiple
Set the multiple property.
selectObject.multiple=true|false
Value | Description |
---|---|
true|false | If the drop-down list supports multiple selection
|
A Boolean type value, true if the drop-down list supports multiple selection, otherwise false.
The following code shows how to check if more than one option in a drop-down list can be selected.
<!DOCTYPE html>
<html>
<body>
<!--from w w w .j a va 2 s.c o m-->
<select id="mySelect">
<option>A</option>
<option>B</option>
<option>C</option>
</select>
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {
var x = document.getElementById("mySelect").multiple;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>
The code above is rendered as follows:
The following code shows how to allow multiple selection in a drop-down list.
<!DOCTYPE html>
<html>
<body>
<!-- w w w . ja va 2s. co m-->
<form>
<select id="mySelect" size="4">
<option>A</option>
<option>B</option>
<option>C</option>
<option>D</option>
</select>
</form>
<button type="button" onclick="myFunction()">test</button>
<script>
function myFunction() {
document.getElementById("mySelect").multiple = true;
}
</script>
</body>
</html>
The code above is rendered as follows: