I'm trying to clear all of the items in an ASP.NET listbox via javascript, but sadly
document.getElementById("<%= lstNames.clientID %>").items.clear;
does not work.
Any ideas would be greatly appreciated!
Thanks,
Jason
I'm trying to clear all of the items in an ASP.NET listbox via javascript, but sadly
document.getElementById("<%= lstNames.clientID %>").items.clear;
does not work.
Any ideas would be greatly appreciated!
Thanks,
Jason
Use jquery document.getElementById("<%= lstNames.clientID %>").empty()
or
document.getElementById("<%= lstNames.clientID %>").options.length = 0;
Use:
document.getElementById("<%= lstNames.clientID %>").selectedIndex = -1; // will throw error on next if there are selected items
document.getElementById("<%= lstNames.clientID %>").options.length = 0;
or
document.getElementById("<%= lstNames.clientID %>").innerHTML = "";