I have this application that lets the user choose his color preferences and change them later when he decides to do so. The app doesn't need to work between page reloads. I want the user to be able to delete a specific color preference from a drop down list. I want to use indexOf and splice but I have struggled to long with it. Here is what I have got up to now. The trouble is in the Remove(). JS Bin: http://jsbin.com/ANENaRid/2/
Here is the trouble function:
function Remove() {
var select = document.getElementById("selectColor");
for (var i = 0; i < colors.length; i--) {
var selectIndex = colors.indexOf(select.value);
if (selectIndex !== -1) {
colors.splice(i, 1);
}
return false;
}
}