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

如何将tr的id设置为变量??????
如何将tr的id设置为变量??????我在js中要调用tr,所以取tr的id但是这个tr是由遍历一个list实现的!所以有多个tr!但是我想标示每个tr所以我想把tr的id设一个变量!!!
<logic:notEmpty name="assetList">
<logic:iterate id="myProject" name="assetList">
<tr id="">
<td class="pagezch">
<bean:write name="myProject" property="attachValue" />
</td>
<td class="pagezch">
<bean:write name="myProject" property="attachDate" />
</td>
<td class="pagezch">
<bean:write name="AsTreatmentDto" property="prepareFeeRate" />%
</td>
<td class="pagezch">
<bean:write name="myProject" property="attachPrepareFee" />
</td>
<td class="pagezch">
<img id="del" src="/asset/images/button_delete.gif" style="cursor:hand" border="0" onclick="validate('<bean:write name="AsTreatmentDto" property="projectID" />','<bean:write name="myProject" property="attachDate" />');" >
</td>
</tr>
</logic:iterate>
</logic:notEmpty>


------解决方案--------------------
JScript code
<%int i=0;%>
<logic:iterate id="myProject" name="assetList"> 
<tr id="<%= i%>"> 
<td class="pagezch"> 
<bean:write name="myProject" property="attachValue" /> 
</td> 
<td class="pagezch"> 
<bean:write name="myProject" property="attachDate" /> 
</td> 
<td class="pagezch"> 
<bean:write name="AsTreatmentDto" property="prepareFeeRate" />% 
</td> 
<td class="pagezch"> 
<bean:write name="myProject" property="attachPrepareFee" /> 
</td> 
<td class="pagezch"> 
   <img id="del"  src="/asset/images/button_delete.gif" style="cursor:hand" border="0" onclick="validate(' <bean:write name="AsTreatmentDto" property="projectID" />',' <bean:write name="myProject" property="attachDate" />');" > 
</td> 
</tr> 
<%i++;%>
</logic:iterate>

------解决方案--------------------
<%int i=0;%>
<logic:iterate id="myProject" name="assetList"> 
<tr id="<%= i%>">
<td class="pagezch"> 
<bean:write name="myProject" property="attachValue" /> 
</td> 
<td class="pagezch"> 
<bean:write name="myProject" property="attachDate" /> 
</td> 
<td class="pagezch"> 
<bean:write name="AsTreatmentDto" property="prepareFeeRate" />% 
</td> 
<td class="pagezch"> 
<bean:write name="myProject" property="attachPrepareFee" /> 
</td> 
<td class="pagezch"> 
<img id="del" src="/asset/images/button_delete.gif" style="cursor:hand" border="0" onclick="validate(' <bean:write name="AsTreatmentDto" property="projectID" />',' <bean:write name="myProject" property="attachDate" />');"