I always used this code to sort the items in the list and then send the order back to the database.
But the code does not work in Firefox or Chrome. It jumps and then clears the contents of the list. It has been used since 2002, works very well in IE.
var list;
function moveUp() {
list = document.forms[0].lists;
var index = list.selectedIndex;
if (index > 0) {
var item = list.options[index];
list.remove(index);
list.add(item, index - 1);
}
}
function moveDown() {
list = document.forms[0].lists;
var index = list.selectedIndex;
if (index > -1 && index < list.options.length - 1) {
var item = list.options[index];
list.remove(index);
list.add(item, index + 1);
}
}
function doSubmit() {
var s = "";
list = document.forms[0].lists;
for (var i = 0; i < list.options.length; i++) {
s += list.options[i].value + " ";
}
document.forms[0].order.value = s;
return false;
}
source
share