// Move the selected items from list box1 to box2 function moveWithRefresh(lstbox1,lstbox2,doRefresh) { var box1Count = lstbox1.options.length; for(var i=0; i < box1Count; i++) { if ( lstbox1.options[i].selected && lstbox1.options[i].value != "" ) { var no = new Option(); no.value = lstbox1.options[i].value; no.text = lstbox1.options[i].text; lstbox2.options[lstbox2.options.length] = no; lstbox1.options[i].value = ""; lstbox1.options[i].text = ""; } } // Delete the items from box1 by setting them to null for ( var i = box1Count - 1; i >= 0; i--) { if ( lstbox1.options[i].value == "" ) lstbox1.options[i] = null; } sortSelect(lstbox1,compareValue); sortSelect(lstbox2,compareValue); // refresh the page if ( doRefresh == 1 ) history.go(0); } function moveAllWithRefresh(lstbox1,lstbox2,doRefresh) { var box1Count = lstbox1.options.length; for(var i=0; i < box1Count; i++) { var no = new Option(); no.value = lstbox1.options[i].value; no.text = lstbox1.options[i].text; lstbox2.options[lstbox2.options.length] = no; lstbox1.options[i].value = ""; lstbox1.options[i].text = ""; } // Delete the items from box1 by setting them to null for ( var i = box1Count - 1; i >= 0; i--) { lstbox1.options[i] = null; } sortSelect(lstbox1,compareValue); sortSelect(lstbox2,compareValue); // refresh the page if ( doRefresh == 1 ) history.go(0); } function move_allRight(lstbox1,lstbox2) { var doRefresh = 0; moveAllWithRefresh(lstbox1,lstbox2,doRefresh); } function move_right(lstbox1,lstbox2) { var doRefresh = 0; moveWithRefresh(lstbox1,lstbox2,doRefresh); } function move_left(lstbox1,lstbox2) { var doRefresh = 0; moveWithRefresh(lstbox2,lstbox1,doRefresh); } function move_allLeft(lstbox1,lstbox2) { var doRefresh = 0; moveAllWithRefresh(lstbox2,lstbox1,doRefresh); } function compareText (option1, option2) { return option1.text < option2.text ? -1 : option1.text > option2.text ? 1 : 0; } function compareValue (option1, option2) { return option1.value < option2.value ? -1 : option1.value > option2.value ? 1 : 0; } function compareTextAsFloat (option1, option2) { var value1 = parseFloat(option1.text); var value2 = parseFloat(option2.text); return value1 < value2 ? -1 : value1 > value2 ? 1 : 0; } function compareValueAsFloat (option1, option2) { var value1 = parseFloat(option1.value); var value2 = parseFloat(option2.value); return value1 < value2 ? -1 : value1 > value2 ? 1 : 0; } function sortSelect (select, compareFunction) { if (!compareFunction) compareFunction = compareText; var options = new Array (select.options.length); for (var i = 0; i < options.length; i++) options[i] = new Option ( select.options[i].text, select.options[i].value, select.options[i].defaultSelected, select.options[i].selected ); options.sort(compareFunction); select.options.length = 0; for (var i = 0; i < options.length; i++) select.options[i] = options[i]; } function cancelConfirm(mesg,redirect) { var answer = confirm(mesg); if(answer) document.location.href=redirect; }