Select multipleProperty

Select 对象参考手册Select Object

Definition and Usage

The multiple property sets or returns whether more than one option can be selected.

Syntax

Setting the multiple property:

selectObject.multiple=true|false

Returning the multiple property:

selectObject.multiple


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the multiple attribute


Examples

Example

Select multiple options in a dropdown:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Example Tutorial (example.com)</title>
<script>
function displayResult(){
    document.getElementById("mySelect").multiple=true;
}
</script>
</head>
<body>

<form>
<select id="mySelect" size="4">
  <option>Apple</option>
  <option>Pear</option>
  <option>Banana</option>
  <option>Orange</option>
</select>
</form>
<button type="button" onclick="displayResult()">Allow multiple selections</button>
<p>Press the Ctrl key to select multiple options</p>

</body>
</html>

Try it Yourself »


Select 对象参考手册Select Object Other Extensions