Monday, March 30, 2009

Remove the selected options from an html select tag

//remove a selected item from list
function removeKeyword()
{
var elSel = document.getElementById("words");//words is the html select tag id
var i = 0;
for (i = elSel.length-1; i>-1; i--) {
if (elSel.options[i].selected) { //check the selected options
elSel.remove(i);//remove the selected options
}
}
}

No comments: