In the following script I can click one item,
use shift to click a range of items
and ctrl-click to select discontinuous items.
I know I can use the ‘selectedIndex’ to get a single selection.
How do I get an array of the multiple items I select?
That what I really want to return instead of the alert message.
Any ideas? ?
[code=php]
<html>
<head>
<title>Multiple Selection Drop Down</title>
<script type=”text/javascript”>
function SetMDDsize(mddSize) {
document.getElementById(‘MultDD’).size = mddSize;
}
function GetMDDselections() {
document.getElementById(‘MultDD’).size = 1; // reduce screen size
alert(‘Display selected options here – How???’); // display all checked option here.
document.getElementById(‘MultDD’).selectedIndex = -1; // reset list
// return string of items selected separated by ‘,’ characters
}
</script>
</head>
<body>
Click, Shift-Click or Ctrl-Click<br />
<select multiple id=”MultDD” size=”1″ onClick=”SetMDDsize(10)”>
<option value=””>-Select-</option>
<option value=”0″>0</option>
<option value=”1″>1</option>
<option value=”2″>2</option>
<option value=”3″>3</option>
<option value=”4″>4</option>
<option value=”5″>5</option>
<option value=”6″>6</option>
<option value=”7″>7</option>
<option value=”8″>8</option>
<option value=”9″>9</option>
</select>
<button id=”MultDDbtn” onClick=”GetMDDselections()”>Get Selections</button>
</body>
</html>