DelphiFAQ Home Search:
General :: Programming :: JavaScript
Code snippets to add functionality to your HTML pages, preferably cross-browser.


This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.

Featured Article

Javascript to clear a listbox


How can I clear a listbox using Javascript?


Use the code below. Call it by passing the listbox object to function clearlistbox()

function clearlistbox(lb){
   for (var i=lb.options.length-1; i>=0; i--){
     lb.options[i] = null;
   lb.selectedIndex = -1;
 // call it like this

Generated 8:01:37 on Sep 25, 2020