Are there any examples out there that will allow me to remove options from drop down list using JavaScript?
Here is the code:
You can remove an option by setting it to null.
document.getElementById("sSec1").options[0] = null;
EDIT:
Here is a working example: http://jsfiddle.net/c5wFn/
document.getElementById("sSec1").addEventListener("change",
function(select)
{
if (this.value != "")
{
var select2 = document.getElementById("sSec2");
for (var i = 0; i < select2.options.length; i++)
{
if (this.value == select2.options[i].value)
{
select2.options[i] = null;
break;
}
}
}
}, false);
The one thing that you will need to work in though is that when an option is changed you need to probably go back through the first list items and add all the non selected items to the list so you put back the question that was removed with the previous selection. It shouldn't be hard I just didn't want to work up all the details.
Also not sure if you are using jquery or not so I worked up with plain old javascript. But the event registration should be tested for compatibility as this won't work on all.