源文件是这样的:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>产品代码</title> <meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0"> <script type="text/javascript" src="/bvp/dwr/engine.js"></script>
<script type="text/javascript" src="/bvp/dwr/util.js"></script>
<script type="text/javascript"
src="/bvp/dwr/interface/orderService.js"></script>
<script type="text/javascript">
function pcode(){
var pcode = document.getElementById("pCode").value;
orderService.getProductCode(pcode,callback);
}
function callback(data){
DWRUtil.removeAllRows("t1"); //此处参数即可为tbody的id,也可以为table的id var cellfuncs = 
[
function(item){return item.CustomerID;},
function(item){return item.SKU;},   //function的参数名可自定义 ;
function(item){return item.Descr_C},
function(item){return item.Descr_E}
]


DWRUtil.addRows('t1', data,cellfuncs,
    {   
        rowCreator:function(options) { //自定义 tr 创建行   
         var row = document.createElement("tr");    
         //row.style.backgroundColor = "rgb(" + (options.rowIndex * 50) + ",100,100)";
 
         row.onmouseover=function() { row.style.backgroundColor = "#3366FF"; }; 
     row.onclick = function(){  alert(data[1].SKU);  }; 
                                row.ondblclick = function(){ window.close();}; 
         return row;    
    }
);   //t1为tbody的id,而不能为table的id
 }


</script>
</head> <body>
<form action="" name="form1" method="post" id="form1">
选择:
<input type="text" name="pCode" id="pCode">
<input type="button" value="查询" onclick="pcode();" />  </form>
<table border='1' width="90%" align="center" id="table" border="0"
cellspacing="0" cellpadding="0">

<tr>
<td>
货主代码
</td>
<td>
SKU
</td>
<td>
中文描述
</td>
<td>
英文描述
</td>
</tr>
<tbody id="t1"></tbody>

</table>
</body>
</html>
就是当这个函数触发是得到它的相关值
     row.onclick = function(){  alert(data[1].SKU);  }; 
我这里面是死值,我想得到他动态的值

解决方案 »

  1.   

    row.onmouseover=function()   {   row.style.backgroundColor   =   "#3366FF ";   };   
    row.onclick   =   function(){     alert(data[1].SKU);     }; 
    这两行都有问题设置动态事件可以这样
    row.onmouseover=function(){this.style.backgroundColor="#3366FF ";}; 
    row.onclick=function(){alert(this.cells(0).innerText);};this在方法里面指向触发该时间的对象,即tr