/* formFunctions ** Version 1.0, 4/21/2003 ** Author: Cody Burleson ** Tested On: IE 6.0.28 ** ** Modified by John P. and Lakky 7/1/2003: Modified to use the value as the key, instead of text. ** */ /* function move(fbox, tbox) ** Moves multiple selected items FROM (fbox), a multi-select listbox, ** TO (tbox), a multi-select listbox. */ function move(fbox, tbox) { var arrFbox = new Array(); // array for FROM box var arrTbox = new Array(); // array for TO box var arrLookup = new Array(); var i; // CONSTRUCT THE arrLookup WITH value and text for (i = 0; i < tbox.options.length; i++) { arrLookup[tbox.options[i].value] = tbox.options[i].text; arrTbox[i] = tbox.options[i].value; } // UPDATE TO AND FROM LIST BASED ON USER SELECTION var fLength = 0; var tLength = arrTbox.length; for(i = 0; i < fbox.options.length; i++) { arrLookup[fbox.options[i].value] = fbox.options[i].text; if (fbox.options[i].selected && fbox.options[i].value != "") { arrTbox[tLength] = fbox.options[i].value; tLength++; } else { arrFbox[fLength] = fbox.options[i].value; fLength++; } } // SORT AND UPDATE THE LIST TO REFLECT THE SELECTED VALUES arrFbox.sort(); arrTbox.sort(); fbox.length = 0; tbox.length = 0; var c; for(c = 0; c < arrFbox.length; c++) { var no = new Option(); no.text = arrLookup[arrFbox[c]]; no.value = arrFbox[c]; fbox[c] = no; } for(c = 0; c < arrTbox.length; c++) { var no = new Option(); no.text= arrLookup[arrTbox[c]]; no.value = arrTbox[c]; tbox[c] = no; } }