读书人

为什么js的onload事件不能触发?马上给

发布时间: 2012-03-06 20:47:55 作者: rapoo

为什么js的onload事件不能触发?马上给分
<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);
}
}
---------------------------
我的datalist里面有个table,多条数据的填产生多个table,我想为table里面的id= "tr_img0 "的td做个自动编序的id,比如有两条数据,那么,这个td的id依次为tr_img1,tr_img2,但是这个td里的onload事件不象里面另一个 <img border= "0 " height= "29 " onload= "javascript:Getid(this) " src= "../images/plus.gif " width= "20 "/> 一样onload触发,请问我怎么达到我的目的?

[解决办法]
帮你顶一下,看不是很明白你的意思
[解决办法]
因为没有事件, <td id= ' <%# Container.ItemIndex+1%> ' value= "xx "> 试试

读书人网 >asp.net

热点推荐