I've used jQuery UI's sortable plugin with good results. Markup similar to this:
<table id="myTable">
<thead>
<tr><th>ID></th><th>Name</th><th>Details</th></tr>
</thead>
<tbody class="sort">
<tr id="1"><td>1</td><td>Name1</td><td>Details1</td><tr>
<tr id="2"><td>2</td><td>Name1</td><td>Details2</td><tr>
<tr id="3"><td>3</td><td>Name1</td><td>Details3</td><tr>
<tr id="4"><td>4</td><td>Name1</td><td>Details4</td><tr>
</tbody>
<table>
and then in the javascript
$('.sort').sortable({
cursor: 'move',
axis: 'y',
update: function(e, ui) {
href = '/myReorderFunctionURL/';
$(this).sortable("refresh");
sorted = $(this).sortable("serialize", 'id');
$.ajax({
type: 'POST',
url: href,
data: sorted,
success: function(msg) {
//do something with the sorted data
}
});
}
});
This POSTs a serialized version of the items' IDs to the URL given. This function (PHP in my case) then updates the items' orders in the database.