By 05/02/2014 6 Comments

How to delete multiple values from the listbox in Javascript

Delete more than one value or multiple values from listbox control

  • You can easily remove multiple values form a listbox object

Following code describes how to delete multiple values from listbox using javascript


function selectBoxRemove(sourceID) { // pass listbox control as a parameter

//get the listbox object by an id.
var src = document.getElementById(sourceID);

//loop through each option from the listbox control
for(var count= src.options.length-1; count >= 0; count--) {

//if the option is selected, delete this option
if(src.options[count].selected == true) {

try {
src.remove(count, null); // call remove function

} catch(error) {

src.remove(count); // handle exception


<select multiple="multiple" id = "listID"> <!--- render listbox object --->
<option value = "java">Java</option>
<option value = "php">Php</option>
<option value = "asp"></option>
<option value = "boot">Bootstraps</option>
<option value = "r">Ruby</option>
<option value = "f">Facebook</option>
<option value = "g">Google</option>
<option value = "c">Css</option>

<!--- following button calls the above function --->
<button onclick="selectBoxRemove('listID')">Remove</button>

Posted in: JavaScript

Leave your valuable Comment

Have a natural attraction for women cosmetics and replica watches uk clothes, no
more than two for men the most attractive one, is to make their own driving experience, happy and can serve as the facade of the car, another is to highlight the taste edify sentiment rolex replica watch. The replica rolex is undoubtedly the most fashionable accessories, wear a suit to attend the activities, but also get a decent match on the replica watches .