Jump to content

remove items


tuzojazz

Recommended Posts

A dropdown box is made of <select> and <option> tags.What you need to do is access the option nodes based on, for example, their value.Here's an example:I'm going to delete the option tag with value "option2"HTML<select id="something"><option value="option1">Option</option><option value="option2">Option</option><option value="option3">Option</option></select>JavaScript

N = document.getElementById("something"); //Get the dropdown boxfor(x=0;x<N.getElementsByTagName("option").length;x++) {// Loop through the dropdown box items  if(N.getElementsByTagName("option")[x].value == "option2") {	N.removeChild(N.getElementsByTagName("option")[x]);  }}

Link to comment
Share on other sites

A dropdown box is made of <select> and <option> tags.What you need to do is access the option nodes based on, for example, their value.Here's an example:I'm going to delete the option tag with value "option2"HTML<select id="something"><option value="option1">Option</option><option value="option2">Option</option><option value="option3">Option</option></select>JavaScript
N = document.getElementById("something"); //Get the dropdown boxfor(x=0;x<N.getElementsByTagName("option").length;x++) {// Loop through the dropdown box items  if(N.getElementsByTagName("option")[x].value == "option2") {	N.removeChild(N.getElementsByTagName("option")[x]);  }}

thanks my friend!! it works!!
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...