Possible Duplicate:
Swapping rows in JQuery
How to move rows up and down in a table on some button click?
Try using jQuery. You can do something like:
<table id="mytable">
<tr>
<td>row 1</td>
<td><input type="button" value="move up" class="move up" /></td>
<td><input type="button" value="move down" class="move down" /></td>
</tr>
...
</table>
$('#mytable input.move').click(function() {
var row = $(this).closest('tr');
if ($(this).hasClass('up'))
row.prev().before(row);
else
row.next().after(row);
});
Look at it working here.
You can also try jQuery's sortable, it is much easier.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With