e.g.
Code:
function clearOptions() {
if (!document.getElementsByTagName) return;
var options = document.getElementById('media_version_id').getElementsByTagName("option"),
oLength = options.length;
for(var i=0; i < oLength; i++) {
options[i].selected = false;
}
}
Code:
<select name="media_version_id" id="media_version_id" size="3" multiple="multiple">
<option value="1">Highlight</option>
<option value="2">Embedded</option>
<option value="3">Standalone</option>
</select>
…
<a href="#" onclick="clearOptions(); return false;">Clear options</a>
Note that the
name attribute of the
select element has also been used for the
id attribute.
What this does is find all the
option elements within an element with
id="media_version_id" and changes each of their
selected attributes to false (unselected).
hth