JavaScript deletes multiple selected elements from the list box at once

From , 3 Years ago, written in JavaScript, viewed 50 times.
URL https://pastebin.vip/view/3fffb98d
  1. function selectBoxRemove(sourceID) {
  2.  
  3.     //get the listbox object from id.
  4.     var src = document.getElementById(sourceID);
  5.    
  6.     //iterate through each option of the listbox
  7.     for(var count= src.options.length-1; count >= 0; count--) {
  8.  
  9.          //if the option is selected, delete the option http://www.sharejs.com
  10.         if(src.options[count].selected == true) {
  11.    
  12.                 try {
  13.                          src.remove(count, null);
  14.                          
  15.                  } catch(error) {
  16.                          
  17.                          src.remove(count);
  18.                 }
  19.         }
  20.     }
  21. }
  22.  
  23.  
  24. //javascript/8785

Reply to "JavaScript deletes multiple selected elements from the list box at once"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website