I have a select box full of options. I want users to be able to rearrage the order of the options listed by selecting an option and then clicking a “Move Up” or Move Down” link that sends the name of the list box and a “+1” for down and “-1” for up to the javascript function below. On the screen it works fine, but my issue is that when the form is submitted the options in the box are sent in the original order they were in before the user changed it even though they are different on the screen. What do I need to do to fix the code.
[CODE]function MoveUpDown(dest,to) {
index = dest.selectedIndex;
var list = dest;
var total = list.options.length-1;
if (index == -1) return false;
if (to == +1 && index == total) return false;
if (to == -1 && index == 0) return false;
var items = new Array;
var values = new Array;
for (i = total; i >= 0; i–) {
items[i] = list.options[i].text;
values[i] = list.options[i].value;
}
for (i = total; i >= 0; i–) {
if (index == i) {
list.options[i + to] = new Option(items[i],values[i + to], 0, 1);
list.options[i] = new Option(items[i + to], values[i]);
i–;
}
else {
list.options[i] = new Option(items[i], values[i]);
}
}
list.focus();
}