日期:2014-05-18  浏览次数:20394 次

动态生成的TableRow指定javascrip的句子应怎样写?
td动态生成的为以下样式:
<td   id= "menu0 "   menulevel= "0 "   songroupid= "menugroup0 "   onmouseover= "MainMenu.onMouseOver(this) "   onmouseout= "MainMenu.onMouseOut(this) "   onclick= "MainMenu.onClick(this) "   class= "menuitem0_default "   style= " "   background= "menu/menuitem0_default_bk_right.gif "   nowrap= "nowrap "> </td>

------解决方案--------------------
给分吧!



var userListTable = document.getElementById( ' <%=tblList.ClientID%> ');//取得Table对象
function renewUserList()
{
var result = SZUM.ZHYW.Report.WebSite.BindOnLineUserList().value;

for ( var i = userListTable.rows.length -1 ; i> 0 ; i -- )
{
userListTable.deleteRow(i);
}

/*
for ( var i = 1 ; i < userListTable.rows.length ; i ++ )
{
userListTable.deleteRow(i);
}*/
if(result.Rows.length> 0)
{
for(var i=0;i <result.Rows.length;i++)
{
myNewRow=userListTable.insertRow(); //动态创建行
myNewCell=myNewRow.insertCell();//动态创建列
myNewCell1=myNewRow.insertCell();
myNewCell2=myNewRow.insertCell();
myNewCell3=myNewRow.insertCell();
myNewCell.innerText= (i+1).toString();
myNewCell1.innerText=result.Rows[i][ "user_name "]; //为列添加数据
myNewCell2.innerText=result.Rows[i][ "ip "];
myNewCell3.innerText=result.Rows[i][ "logon_date "];
}
}
setTimeout( "renewUserList(); ",3000);
window.status += '-A '
}