Setting the value to null will work but make sure that you lesson the loop on each iteration that you remove a option. Such as
function removeSelectOption(objSelect, strValue)
{
for (i=0;i<objSelect.options.length;i++)
{
if (objSelect.options.value == strValue)
{
objSelect.options = null;
i--;
}
}
} //removeSelectOption
This may not matter in you particular case, but I ran into this problem when trying to remove multiple options at once. Because every time you remove an option, the options array becomes 1 smaller. And if you try to set an option to null that no longer exists it will throw an error in certain browsers. Just something to keep in mind.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.