js table 行上移、下移

来源:互联网 发布:推荐数据统计分析的书 编辑:程序博客网 时间:2024/05/20 09:07

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<title></title>

<script type="text/javascript"> 
//使表格行上移,接收参数为链接对象
function moveUp(_a,orderId){ 
//通过链接对象获取表格行的引用
var _row=_a.parentNode.parentNode;
//var curRow = null;
var tdSeq = _row.rowIndex - 1;
//如果不是第一行,则与上一行交换顺序
if(_row.previousSibling){

swapNode(_row,_row.previousSibling);
}
}
//使表格行下移,接收参数为链接对象
function moveDown(_a,orderId){
//通过链接对象获取表格行的引用
var _row=_a.parentNode.parentNode;
var tdSeq = _row.rowIndex + 1;
//如果不是最后一行,则与下一行交换顺序
if(_row.nextSibling){
swapNode(_row,_row.nextSibling);
}
}
//定义通用的函数交换两个结点的位置
function swapNode(node1,node2){
//获取父结点
var _parent=node1.parentNode;
//获取两个结点的相对位置
var _t1=node1.nextSibling;
var _t2=node2.nextSibling;
//将node2插入到原来node1的位置
if(_t1)_parent.insertBefore(node2,_t1);
else _parent.appendChild(node2);
//将node1插入到原来node2的位置
if(_t2)_parent.insertBefore(node1,_t2);
else _parent.appendChild(node1);
}
/**
* function move to top
* _a thisRow a
*/
function moveToTop(_a){ 
var _row=_a.parentNode.parentNode;
var _parent= _row.parentNode;
if (_row.rowIndex != 1)
_parent.moveRow(_row.rowIndex-1, 0);
}
/**
* function move to bottom
* _a thisRow a
*/
function moveToBottom(_a){
var _row=_a.parentNode.parentNode;// 该行信息 
var _parent= _row.parentNode;// 父节点
_parent.appendChild(_row);
}
//-->
</script>


</head>
<body>
<div id="toolbar"></div>

<div id="p-main" style="border:0;margin:5px;" >
<form method="post"> 
<table id="resultTable" class="tablesorter" border="1">
<thead>
<tr>
<th>段落标题</th>
<th>排序</th>
</tr>
</thead>
<tbody>

<tr id="0">
<td width="600px">
<input type="hidden" name="blockInfoList[0].id" value="402881d92cbf6b2a012cbf7426380003" id="block_order_edit_blockInfoList_0__id"/>
<input type="hidden" name="blockInfoList[0].name" value="江阴中达" id="block_order_edit_blockInfoList_0__name"/>
<input type="hidden" name="blockInfoList[0].questionnaireId" value="402881d92cbf6b2a012cbf7424730001" id="block_order_edit_blockInfoList_0__questionnaireId"/>
<input type="hidden" name="blockInfoList[0].proportion" value="0.0" id="block_order_edit_blockInfoList_0__proportion"/>
<input type="hidden" name="blockInfoList[0].useSupplyer" value="1" id="block_order_edit_blockInfoList_0__useSupplyer"/> 
江阴中达
</td>
<td align="center"> 
<input type="hidden" name="blockInfoList[0].orderId" value="1" id="pn_0" class="easyui-numberbox"/>
<input type="button" id="addAll" value="置顶" onclick='moveToTop(this)'/>
<input type="button" id="addAll" value="上移" onclick='moveUp(this,0)'/>
<input type="button" id="addAll" value="下移" onclick="moveDown(this,0)"/> 
<input type="button" id="addAll" value="置底" onclick='moveToBottom(this)'/> 
</td>
</tr>

<tr id="1">
<td width="600px">
<input type="hidden" name="blockInfoList[1].id" value="402881d92cbf6b2a012cbf7426a60004" id="block_order_edit_blockInfoList_1__id"/>
<input type="hidden" name="blockInfoList[1].name" value="云南昆岭" id="block_order_edit_blockInfoList_1__name"/>
<input type="hidden" name="blockInfoList[1].questionnaireId" value="402881d92cbf6b2a012cbf7424730001" id="block_order_edit_blockInfoList_1__questionnaireId"/>
<input type="hidden" name="blockInfoList[1].proportion" value="0.0" id="block_order_edit_blockInfoList_1__proportion"/>
<input type="hidden" name="blockInfoList[1].useSupplyer" value="1" id="block_order_edit_blockInfoList_1__useSupplyer"/> 
云南昆岭
</td>
<td align="center"> 
<input type="hidden" name="blockInfoList[1].orderId" value="2" id="pn_1" class="easyui-numberbox"/>
<input type="button" id="addAll" value="置顶" onclick='moveToTop(this)'/>
<input type="button" id="addAll" value="上移" onclick='moveUp(this,1)'/>
<input type="button" id="addAll" value="下移" onclick="moveDown(this,1)"/> 
<input type="button" id="addAll" value="置底" onclick='moveToBottom(this)'/> 
</td>
</tr>

<tr id="2">
<td width="600px">
<input type="hidden" name="blockInfoList[2].id" value="402881d92cbf6b2a012cbf7426e40005" id="block_order_edit_blockInfoList_2__id"/>
<input type="hidden" name="blockInfoList[2].name" value="湛江公司" id="block_order_edit_blockInfoList_2__name"/>
<input type="hidden" name="blockInfoList[2].questionnaireId" value="402881d92cbf6b2a012cbf7424730001" id="block_order_edit_blockInfoList_2__questionnaireId"/>
<input type="hidden" name="blockInfoList[2].proportion" value="0.0" id="block_order_edit_blockInfoList_2__proportion"/>
<input type="hidden" name="blockInfoList[2].useSupplyer" value="1" id="block_order_edit_blockInfoList_2__useSupplyer"/> 
湛江公司
</td>
<td align="center"> 
<input type="hidden" name="blockInfoList[2].orderId" value="3" id="pn_2" class="easyui-numberbox"/>
<input type="button" id="addAll" value="置顶" onclick='moveToTop(this)'/>
<input type="button" id="addAll" value="上移" onclick='moveUp(this,2)'/>
<input type="button" id="addAll" value="下移" onclick="moveDown(this,2)"/> 
<input type="button" id="addAll" value="置底" onclick='moveToBottom(this)'/> 
</td>
</tr>

<tr id="3">
<td width="600px">
<input type="hidden" name="blockInfoList[3].id" value="402881d92cbf6b2a012cbf7427130006" id="block_order_edit_blockInfoList_3__id"/>
<input type="hidden" name="blockInfoList[3].name" value="英诺公司" id="block_order_edit_blockInfoList_3__name"/>
<input type="hidden" name="blockInfoList[3].questionnaireId" value="402881d92cbf6b2a012cbf7424730001" id="block_order_edit_blockInfoList_3__questionnaireId"/>
<input type="hidden" name="blockInfoList[3].proportion" value="0.0" id="block_order_edit_blockInfoList_3__proportion"/>
<input type="hidden" name="blockInfoList[3].useSupplyer" value="1" id="block_order_edit_blockInfoList_3__useSupplyer"/> 
英诺公司
</td>
<td align="center"> 
<input type="hidden" name="blockInfoList[3].orderId" value="4" id="pn_3" class="easyui-numberbox"/>
<input type="button" id="addAll" value="置顶" onclick='moveToTop(this)'/>
<input type="button" id="addAll" value="上移" onclick='moveUp(this,3)'/>
<input type="button" id="addAll" value="下移" onclick="moveDown(this,3)"/> 
<input type="button" id="addAll" value="置底" onclick='moveToBottom(this)'/> 
</td>
</tr>

<tr id="4">
<td width="600px">
<input type="hidden" name="blockInfoList[4].id" value="402881d92cbf6b2a012cbf7427420007" id="block_order_edit_blockInfoList_4__id"/>
<input type="hidden" name="blockInfoList[4].name" value="请您对材料质量情况作出评价" id="block_order_edit_blockInfoList_4__name"/>
<input type="hidden" name="blockInfoList[4].questionnaireId" value="402881d92cbf6b2a012cbf7424730001" id="block_order_edit_blockInfoList_4__questionnaireId"/>
<input type="hidden" name="blockInfoList[4].proportion" value="0.0" id="block_order_edit_blockInfoList_4__proportion"/>
<input type="hidden" name="blockInfoList[4].useSupplyer" value="0" id="block_order_edit_blockInfoList_4__useSupplyer"/> 
请您对材料质量情况作出评价
</td>
<td align="center"> 
<input type="hidden" name="blockInfoList[4].orderId" value="5" id="pn_4" class="easyui-numberbox"/>
<input type="button" id="addAll" value="置顶" onclick='moveToTop(this)'/>
<input type="button" id="addAll" value="上移" onclick='moveUp(this,4)'/>
<input type="button" id="addAll" value="下移" onclick="moveDown(this,4)"/> 
<input type="button" id="addAll" value="置底" onclick='moveToBottom(this)'/> 
</td>
</tr>

<tr id="5">
<td width="600px">
<input type="hidden" name="blockInfoList[5].id" value="402881d92cbf6b2a012cbf7424b20002" id="block_order_edit_blockInfoList_5__id"/>
<input type="hidden" name="blockInfoList[5].name" value="填表单位信息" id="block_order_edit_blockInfoList_5__name"/>
<input type="hidden" name="blockInfoList[5].questionnaireId" value="402881d92cbf6b2a012cbf7424730001" id="block_order_edit_blockInfoList_5__questionnaireId"/>
<input type="hidden" name="blockInfoList[5].proportion" value="0.0" id="block_order_edit_blockInfoList_5__proportion"/>
<input type="hidden" name="blockInfoList[5].useSupplyer" value="0" id="block_order_edit_blockInfoList_5__useSupplyer"/> 
填表单位信息
</td>
<td align="center"> 
<input type="hidden" name="blockInfoList[5].orderId" value="6" id="pn_5" class="easyui-numberbox"/>
<input type="button" id="addAll" value="置顶" onclick='moveToTop(this)'/>
<input type="button" id="addAll" value="上移" onclick='moveUp(this,5)'/>
<input type="button" id="addAll" value="下移" onclick="moveDown(this,5)"/> 
<input type="button" id="addAll" value="置底" onclick='moveToBottom(this)'/> 
</td>
</tr> 
</tbody>
</table> 
</form>
</div>
</body>
</html>

原创粉丝点击