We Recommend

Pro JavaScript Techniques Pro JavaScript Techniques
Pro JavaScript Techniques is the ultimate JavaScript book for the modern web developer. It provides everything you need to know about modern JavaScript, and shows what JavaScript can do for your web sites. This book doesn't waste any time looking at things you already know, like basic syntax and structures.


Posted By

indianocean on 11/30/07


Tagged

html javascript


Versions (?)


Who likes this?

1 person has marked this snippet as a favorite

vali29


Delete item from HTML option list


Published in: JavaScript 


  1. var optValue = 3; // value of the item to delete
  2. var myOptionList = document.getElementById("myList");
  3. var theposition= '';
  4. for(var i=0;i<myOptionList.length;i++)
  5. {
  6. if(myOptionList.options[i].value == optValue);
  7. {
  8. theposition = myOptionList.options[i].index;
  9. }
  10. }
  11. myOptionList.remove(theposition);

Report this snippet 

You need to login to post a comment.