Clearing or removing all the options or list items from a select box/listbox in Javascript is easily accomplished with one short line of Javascript code.
If you want to remove only specific items from an HTML select box then ...
document.getElementById('idOfSelect').options.remove(indexOfItem);
replacing indexOfItem
with the index number of the select option you want to remove, ie ...
... the above Javascript code would remove the second option element from the HTML select element with an id of idOfSelect
.
Try it yourself. Click the button to clear all the options from the HTML select box below. Right click this page and click VIEW SOURCE to view the code associated with clearing all options from HTML select element.