Jump to content

remove items


tuzojazz
 Share

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...