Clearing combobox items using javascript
By Anuraj P on May 23rd, 2007 . No Comments .
I already posted some code to add and read values from dropdown lists using Javascript. Sometimes we require to reset the items to zero or need to clear the items in the dropdown list. Here is a simple code snippet which will reset the dropdown items.
function clearDropdown(dropdown)
{
var mycombo =document.getElementById(dropdown);
mycombo.options.length = 0;
return(false);
}
And you can use this function like this
<button onclick="javascript:clearDropdown('myoptions')">Reset Options</button>
Where myoptions is the dropdown to clear.
No Responses to “Clearing combobox items using javascript”
RSS feed for comments on this post. TrackBack URL