<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
html, body{
font-size:12px;
}
table{
border-collapse:collapse;
}
</style>
<script type="text/javascript">
function $(id){
return document.getElementById(id);
}
function getTable(row){
while(row && row.tagName.toLowerCase() != "table"){
row = row.parentNode;
}
return row;
}
function clickRow(row){
if(row.style.backgroundColor == ""){
row.style.backgroundColor = "#EEE";
}else{
row.style.backgroundColor = "";
}
}
function dblclickRow(row){
row.style.backgroundColor = "";
moveRow(row);
}
function moveRow(row){
var ts = getTable(row);
var td = null;
if(ts.id == "tbSource"){
td = $("tbDest");
}else{
td = $("tbSource");
}
td.getElementsByTagName("tbody")[0].appendChild(row);
}
function moveTable(id){
var tb = $(id);
var len = tb.rows.length;
for(var i=len-1; i>=0; i--){
if(tb.rows[i].style.backgroundColor != ""){
tb.rows[i].style.backgroundColor = "";
moveRow(tb.rows[i]);
}
}
}
window.onload = function(){
var tbSource = $("tbSource");
for(var i=0; i<tbSource.rows.length; i++){
tbSource.rows[i].onclick = function(){
clickRow(this);
};
tbSource.rows[i].ondblclick = function(){
dblclickRow(this);
};
}
};
</script>
</head>
<body>
<table width="600" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center" valign="top"><table width="260" border="1" cellspacing="0" cellpadding="6" id="tbSource">
<tr>
<td bgcolor="#CCCCCC"><strong>ID</strong></td>
<td bgcolor="#CCCCCC"><strong>姓名</strong></td>
<td bgcolor="#CCCCCC"><strong>货物</strong></td>
<td bgcolor="#CCCCCC"><strong>件数</strong></td>
</tr>
<tr>
<td>1</td>
<td>A</td>
<td>D</td>
<td>5</td>
</tr>
<tr>
<td>2</td>
<td>B</td>
<td>E</td>
<td>87</td>
</tr>
<tr>
<td>3</td>
<td>C</td>
<td>F</td>
<td>4</td>
</tr>
</table></td>
<td align="center"><input type="button" name="btn1" id="btn1" value=" >> " οnclick="moveTable('tbSource');" /><br /><br />
<input type="button" name="btn2" id="btn2" value=" << " οnclick="moveTable('tbDest');" /></td>
<td align="center" valign="top">
<table width="260" border="1" cellspacing="0" cellpadding="6" id="tbDest">
<tr>
<td bgcolor="#CCCCCC"><strong>ID</strong></td>
<td bgcolor="#CCCCCC"><strong>姓名</strong></td>
<td bgcolor="#CCCCCC"><strong>货物</strong></td>
<td bgcolor="#CCCCCC"><strong>件数</strong></td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>