|
<asp: DataList runat = "server" Id = "dlCategories" BorderWidth = "0" Width = "100%" GridLines = "Both" Bordercolor = "White" OnItemDataBound = "dlCategories_ItemDataBound" BorderStyle = "None">
<ItemTemplate>
<table align = "center" border = "0" cellpadding = "0" cellspacing = "0" width = "130">
<tr>
<td background = "../ images / left_01.jpg" style = "height: 26px">
<table align = "center" border = "0" cellpadding = "0" cellspacing = "0" width = "98%">
<tr>
<td width = "20" style = "height: 29px">
<img border = "0" height = "29" onload = "javascript: Getid (this)" src = "../ images / plus.gif" width = "20" /> </ td>
<td style = "height: 29px; text-align: center">
<table border = "0" cellpadding = "0" cellspacing = "0" width = "100%">
<tr>
<td style = "height: 4px">
</ td>
</ tr>
</ table>
<asp: Label ID = "Label1" runat = "server" onClick = "javascript: HiddenOrShow (document.getElementById ('img1'))" Text = '<% # DataBinder.Eval (Container, "DataItem.level1_name")% > 'Font-Size = "Small" ForeColor = "White" Font-Bold = "True"> </ asp: Label> </ td>
</ tr>
</ table>
</ td>
</ tr>
<tr style = "color: # 0000ff; text-decoration: underline">
<td id = "tr_img0" onload = "javascript: Gettdid (this)" valign = "bottom">
</ ItemTemplate>
<HeaderStyle BackColor = "# DDDDDD" Font-Bold = "True" Font-Names = "Arial" Font-Size = "14pt"
ForeColor = "# 777777" />
</ asp: DataList>
-------------------------------------------------- -----------
var checkid = 0;
var countid = 0;
function Getid (obj)
{
if (checkid == countid)
{
checkid = checkid + 1;
countid = countid + 1;
var b = "img" + countid;
obj.id = b;
}
}
var checkid2 = 0;
var countid2 = 0;
function Gettdid (obj)
{
if (checkid2 == countid2)
{
countid2 = countid2 + 1;
checkid2 = checkid2 + 1;
var b = "tr_img" + countid2;
obj.id = b;
var a = obj.id;
alert (a);
}
}
-------------------------------------------------- -------------
There is a table in my datalist, and multiple tables are filled to generate multiple tables. I want to make an auto-sequenced id for td with id = "tr_img0" in the table.For example, if there are two data, then this td The ids are tr_img1 and tr_img2, but the onload event in this td is not like the other <img border = "0" height = "29" onload = "javascript: Getid (this)" src = "../ images / plus .gif "width =" 20 "/> is triggered like onload, how can I achieve my purpose? |
|