garethhall Posted November 14, 2009 Share Posted November 14, 2009 Hello, I have this function that runs when you click a button. This functions take the selected items from box A adds it to box B and removes it from box A. Now this works ok but, as soon as you do a second selection then the remove from box A don't work. Any help would be great function addExt(){ var toRemExt = new Array(); //Create array to hold items to remove elm = document.getElementById('ext'); for(e = 0; e < elm.length; e++){ //loop all the select box items if(elm.options[e].selected){ //work with only the selected items addOption(document.frmExt.curExt, elm.options[e].value, elm.options[e].value); //Add option approved side toRemExt[e] = elm.options[e].value; //write item value to the array } /*** If at the end off the loop remove the items matching the array ***/ if(e == (tExt-1)){ for(a = 0; a < toRemExt.length; a++){ //loop throught the array for(f = 0; f < elm.length; f++){ //for each item in the array loop through the items in the select box if(toRemExt[a] == elm.options[f].value){ //if items match then removeOption(document.frmExt.ext,f); //remove item from select box } } } } //endif } } Quote Link to comment Share on other sites More sharing options...
JustLikeIcarus Posted November 16, 2009 Share Posted November 16, 2009 Why not just do function addExt(){ var toRemExt = new Array(); //Create array to hold items to remove elm = document.getElementById('ext'); for(e = 0; e < elm.length; e++){ //loop all the select box items if(elm.options[e].selected){ //work with only the selected items addOption(document.frmExt.curExt, elm.options[e].value, elm.options[e].value); //Add option approved side removeOption(document.frmExt.ext,e); //remove item from select box } } } [code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.