藍森林首頁 | 返回主頁 | 本站地圖 | 站內搜索 | 聯繫信箱 |
 您目前的位置:首頁 > 自由軟件 > 技術交流 > 應用編程


    

藍森林 http://www.lslnet.com 2006年8月25日 8:28

請教實現tr上下移動的效果代碼

類似下載軟件中使下載任務上下移動的功能,網頁上能實現嗎?

應該可以吧!

怎麼做,有代碼沒有,推薦給我用用,十分感謝

關注ing

是不是這樣的效果?
[html]

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title></title>
<style>
td{
font-size:12px;
}
</style>
<script>
var currobj,currindex=-1;

function showindex(){
if(currobj != null && currobj.tagName == "TR") currobj.bgColor="#eeeeee";
currobj = event.srcElement.parentElement;
if(currobj.tagName == "TR") {
currobj.bgColor=="#eeeeee"?currobj.bgColor="#fefefe":currobj.bgColor="#eeeeee";
currindex = currobj.rowIndex;
}
}

function movetr(){
if(currindex==-1) {alert("請先選擇");return;}
if(event.srcElement.name=="b1" && currindex>0){
mytable.moveRow(currindex,currindex-1);
currindex-=1;
}
if(event.srcElement.name=="b2" && currindex<4){
mytable.moveRow(currindex,currindex+1);
currindex+=1;
}
}
</script>
</head>
<body style="overflow:auto">
<table width="80%" height="100%"  border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td align="center"><table width="90%"  border="0" cellpadding="4" cellspacing="1" bgcolor="#333333" onclick="showindex()" id="mytable">
      <tr bgcolor="#eeeeee">
        <td>1</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr bgcolor="#eeeeee">
        <td>2</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr bgcolor="#eeeeee">
        <td>3</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr bgcolor="#eeeeee">
        <td>4</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr bgcolor="#eeeeee">
        <td>5</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
    </table></td>
    <td width="1"><input type="button" name="b1" value="↑" onClick="movetr()"><br><input type="button" name="b2" value="↓" onClick="movetr()"></td>
  </tr>
</table>
[/html]




Copyright © 1999-2000 LSLNET.COM. All rights reserved. 藍森林網站 版權所有。 E-mail : webmaster@lslnet.com