Link to home
Start Free TrialLog in
Avatar of tolppa
tolppa

asked on

How do I delete an option from html select element?

How do I delete an option from a html select element? I would like to do somehing like this:

var selectElement= document.getElementById(idparam);
selectElement.options[5].remove();

Open in new window


I am not able to do something like this because element exist in variable:

$('#idvalue option[value=' + val + ']').remove();

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of tolppa
tolppa

ASKER

Thanks. Seems like selectElement.options[5].remove(); does not work with IE. x.remove(x.selectedIndex); seems to work better.