Swaprows
From Federal Burro of Information
<html>
<head>
<script> Node.prototype.swapNode = function (node) { var nextSibling = this.nextSibling; var parentNode = this.parentNode; node.parentNode.replaceChild(this, node); parentNode.insertBefore(node, nextSibling); } Node.prototype.swapCardinal = function (node) { var srcCardinal = this.cells[2].childNodes[0].value; var dstCardinal = node.cells[2].childNodes[0].value; this.cells[2].childNodes[0].value = dstCardinal ; node.cells[2].childNodes[0].value = srcCardinal ; }
function nextRow(obj) { var row = obj.parentNode.parentNode; var tbody = row.parentNode; var nextrow = tbody.rows[row.sectionRowIndex]; if ( nextrow ) { alert ( nextrow.id + " " + nextrow.rowIndex ) ; } }
function MoveDown(obj) { var row = obj.parentNode.parentNode; var tbody = row.parentNode; var nextrow = tbody.rows[row.sectionRowIndex+1]; if ( nextrow ) { row.swapNode(nextrow); row.swapCardinal(nextrow); } } function MoveUp(obj) { var row = obj.parentNode.parentNode; var tbody = row.parentNode; var previousrow = tbody.rows[row.sectionRowIndex-1]; if ( previousrow ) { row.swapNode(previousrow); row.swapCardinal(previousrow); } } </script>
</head>
<body>
<form name="myform" method="post" action="" enctype="application/x-www-form-urlencoded">
<thead> </thead> <tbody>Name | Max Age | Importance | |
David | <input type=text size=4 name="DavidMaxAge"> | <input type=text size=4 name="DavidCardinal"> |
<input type=button onclick="MoveDown(this)" value="Down"> <input type=button onclick="MoveUp(this)" value="Up"> |
Luc | <input type=text size=4 name="LucMaxAge"> | <input type=text size=4 name="LucCardinal"> |
<input type=button onclick="MoveDown(this)" value="Down"> <input type=button onclick="MoveUp(this)" value="Up"> |
James | <input type=text size=4 name="JamesMaxAge"> | <input type=text size=4 name="JamesCardinal"> |
<input type=button onclick="MoveDown(this)" value="Down"> <input type=button onclick="MoveUp(this)" value="Up"> |
</form> </body>