Hello all! I have seen posts for moving/adding options from a select box with buttons, but I am working on a script to allow options to be moved/removed onclick of option. Below is my code. My problem is after 2 options have been selected and placed into the second select box (saved options) everytime an option is clicked after that it doubles...
Please help, thanks in advanced.
Kudos!!
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++){
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 if(savLen>0){
for(i=0; i<savLen; i++){
// alert(document.add['store[]'].options[j].value+'=='+document.add['saved[]'].value);
if(document.add['store[]'].options[j].value==document.add['saved[]'].value){
document.add['saved[]'].remove(document.add['saved[]'].options.selectedIndex);
}
if(document.add['store[]'].options[j].value!=document.add['saved[]'].value){
s=sel1.split("|");
document.add['saved[]'].options[document.add['saved[]'].options.length]=new Option(s[2], sel1);
}
}
}
}
}
}
Please help, thanks in advanced.
Kudos!!
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++){
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 if(savLen>0){
for(i=0; i<savLen; i++){
// alert(document.add['store[]'].options[j].value+'=='+document.add['saved[]'].value);
if(document.add['store[]'].options[j].value==document.add['saved[]'].value){
document.add['saved[]'].remove(document.add['saved[]'].options.selectedIndex);
}
if(document.add['store[]'].options[j].value!=document.add['saved[]'].value){
s=sel1.split("|");
document.add['saved[]'].options[document.add['saved[]'].options.length]=new Option(s[2], sel1);
}
}
}
}
}
}