日期:2014-05-16  浏览次数:20345 次

javascript 拖动排序代码
求一拖动并且可以排序的代码?上下排序就可以的
谢谢了?
急急急!

------解决方案--------------------
参考:
http://www.v-ec.com/dh20156/code/dhdatagrid/index.asp
------解决方案--------------------
上边链接的blog真漂亮,想注册一个,一看...是程序员专用的..唉

还发现一个老大级人物
http://www.v-ec.com/dh20156/code/regexp.htm

啊....哈
------解决方案--------------------
<html>
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 ">
<title> JK:支持民族工业,尽量少买X货 </title>
<script language= "javascript ">
var beginMoving=false;
function MouseDownToMove(obj){
obj.style.zIndex=1;
obj.mouseDownY=event.clientY;
obj.mouseDownX=event.clientX;
beginMoving=true;
obj.setCapture();
}

function MouseMoveToMove(obj){
if(!beginMoving) return false;
obj.style.top = (event.clientY-obj.mouseDownY);
obj.style.left = (event.clientX-obj.mouseDownX);
}
function MouseUpToMove(obj){
if(!beginMoving) return false;
obj.releaseCapture();
obj.style.top=0;
obj.style.left=0;
obj.style.zIndex=0;
beginMoving=false;
var tempTop=event.clientY-obj.mouseDownY;
var tempRowIndex=(tempTop-tempTop%25)/25;
if(tempRowIndex+obj.rowIndex <0 )tempRowIndex=-1;
else tempRowIndex=tempRowIndex+obj.rowIndex;
if(tempRowIndex > = obj.parentElement.rows.length-1) tempRowIndex = obj.parentElement.rows.length-1;
obj.parentElement.moveRow(obj.rowIndex,tempRowIndex);
obj.parentNode.insertBefore(obj,obj.nextSibling);//Add this to fix a IE bug(JK2007-07-17)
}

</script>
</head>
<body >
用鼠标移动TR <br>
<TABLE WIDTH= "300 " BORDER= "1 " >

<TR bgcolor=#ffffff style= 'height:25;position:relative; ' onmousedown= 'MouseDownToMove(this) ' onmousemove= 'MouseMoveToMove(this) ' onmouseup= 'MouseUpToMove(this); '> <TD bgcolor=blue> 0 </TD> <TD> 0 </TD> <TD> 0 </TD> </TR>
<TR bgcolor=#ffffff style= 'height:25;position:relative; ' onmousedown= 'MouseDownToMove(this) ' onmousemove= 'MouseMoveToMove(this) ' onmouseup= 'MouseUpToMove(this); '> <TD bgcolor=black> 1 </TD> <TD> 1 </TD> <TD> 1 </TD> </TR>
<TR bgcolor=#ffffff style= 'height:25;position:relative; ' onmousedown= 'MouseDownToMove(this) ' onmousemove= 'MouseMoveToMove(this) ' onmouseup= 'MouseUpToMove(this); '> <TD bgcolor=red> 2 </TD> <TD> 2 </TD> <TD> 2 </TD> </TR>
<TR bgcolor=#ffffff style= 'height:25;position:relative; ' onmousedown= 'MouseDownToMove(this) ' onmousemove= 'MouseMoveToMove(this) ' onmouseup= 'MouseUpToMove(this); '> <TD> 3 </TD> <TD> 3 </TD> <TD> 3 </TD> </TR>
<TR bgcolor=#ffffff style= 'height:25;position:relative; ' onmousedown= 'MouseDownToMove(this) ' onmousemove= 'MouseMoveToMove(this) ' onmouseup= 'MouseUpToMove(this); '> <TD> 4 </TD> <TD> 4 </TD> <TD> 4 </TD> </TR>
<TR bgcolor=#ffffff style= 'height:25;position:relative; ' onmousedown= 'MouseDownToMove(this) ' onmousemove= 'MouseMoveToMove(this) ' onmouseup= 'MouseUpToMove(this); '> <TD> 5 </TD> <TD> 5 </TD> <TD> 5 </TD> </TR>