I have a javascript method which handles removing from one select box to another. The code runs as follows :
function moveAllOptions(formName, selectId1, selectId2) {
var sourceSelect = eval("document." + formName + "." + selectId1);
var destSelect = eval("document." + formName + "." + selectId2);
for (var i = 0; i < sourceSelect.length; i++) {
var optionText = sourceSelect.options[i].text;
var optionValue = sourceSelect.options[i].value;
for (var j = 0; j < destSelect.length; j++) {
if (destSelect.options[j].value == optionValue) {
destSelect.options[j].value = null;
}
}
}
}
But I found a problem like when it encounters duplicate values it is not deleting all the values .For eg: in the view source I have
value="139">Customer Service<
value="231">Customer Service<
value="231">Customer Service<
value="231">Customer Service<
value="231">Customer Service<
In this case it removes only two objects from my left hand box. Is there any way to remove duplicate objects also.One way I could think is create an two array objects(Two Dimensional), pass all the values in left hand side to one array then iterate to another array and finally pass again to normal options.