Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help!! Removing an option from multiple select via selection in first

Status
Not open for further replies.

PBE3

Programmer
Aug 16, 2007
25
US
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);
}
}
}
}
}
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top