<logic:iterate id="app" name="apps">
<tr>
<td id="aid" align="center"><bean:write name="app" property="app_aid"/></td>
<td id="nameid" align="center"><bean:write name="app" property="app_name"/></td>
<td id="status" align="center"><bean:write name="app" property="app_status"/>&nbsp;&nbsp;<a href="#" onclick="changestatus('aid','nameid','status')"/>更改</a></td>
</tr>
</logic:iterate>这样的话每一行tr中td的id都会相同,但我又要用td中的值作为changestatus函数中的参数,我想通过id来获得td的值,但td的id相同,会出错。请问这样用td中的值来作为参数传给changestatus。

解决方案 »

  1.   

    在list中加一递增列,从1到n.列名叫seq.
    <logic:iterate id="app" name="apps" > 
    <tr > 
    <td id="aid<bean:write name="app" property="seq"/ >" align="center" > <bean:write name="app" property="app_aid"/ > </td > 
    <td id="nameid<bean:write name="app" property="seq"/ >" align="center" > <bean:write name="app" property="app_name"/ > </td > 
    <td id="status<bean:write name="app" property="seq"/ >" align="center" > <bean:write name="app" property="app_status"/ >&nbsp;&nbsp; 
    <a href="#" onclick="changestatus( 'aid<bean:write name="app" property="seq"/ >',
     'nameid<bean:write name="app" property="seq"/ > ',
     'status<bean:write name="app" property="seq"/ > ')"/ >更改 </a > </td > 
    </tr > 
    </logic:iterate >