Hello all -
I have written a function in which upon select places the option selected into a second select box. If the option is selected and it is already in the second select box I am trying to have it remove the option from the second select box.
It places the options in the second box but when I add a second option it multiplies and if I go to remove it removes multiple.
Any suggestions?
Here is my code:
function savedAccess(){
savLen=document.add['saved[]'].length;
storeLen=document.add.store.length;
//alert(savLen);
sel1=document.add.store[document.add.store.selectedIndex].value;
//alert(sel1);
for(j=0; j<storeLen; j++){
// alert('for 1');
if(document.add.store.options[j].selected){
alert(document.add.store.options[j].value);
if(savLen==0){
s=sel1.split("|");
document.add['saved[]'].options[document.add['saved[]'].options.length]=new Option(s[2], sel1);
}else{
for(i=0; i<savLen; i++){
if(document.add.store[j].selected.value==document.add['saved[]'].value){
for(l=document.add.store.options[j].length; l>-1; l--){
document.add['saved[]'].remove(document.add['saved[]'].options.selectedIndex);
}
}else{
s=sel1.split("|");
document.add['saved[]'].options[document.add['saved[]'].options]=new Option(s[2], sel1);
}
}
}
}
}
}
I have written a function in which upon select places the option selected into a second select box. If the option is selected and it is already in the second select box I am trying to have it remove the option from the second select box.
It places the options in the second box but when I add a second option it multiplies and if I go to remove it removes multiple.
Any suggestions?
Here is my code:
function savedAccess(){
savLen=document.add['saved[]'].length;
storeLen=document.add.store.length;
//alert(savLen);
sel1=document.add.store[document.add.store.selectedIndex].value;
//alert(sel1);
for(j=0; j<storeLen; j++){
// alert('for 1');
if(document.add.store.options[j].selected){
alert(document.add.store.options[j].value);
if(savLen==0){
s=sel1.split("|");
document.add['saved[]'].options[document.add['saved[]'].options.length]=new Option(s[2], sel1);
}else{
for(i=0; i<savLen; i++){
if(document.add.store[j].selected.value==document.add['saved[]'].value){
for(l=document.add.store.options[j].length; l>-1; l--){
document.add['saved[]'].remove(document.add['saved[]'].options.selectedIndex);
}
}else{
s=sel1.split("|");
document.add['saved[]'].options[document.add['saved[]'].options]=new Option(s[2], sel1);
}
}
}
}
}
}