我在 Struts 2 中有一个动态表。我想在其中将迭代器索引值传递给 Javascript 函数。我怎样才能做到这一点?我已经给出了下面的代码。
这是我的桌子:
<table class="tblborder" id="priorIncident">
<thead>
<tr bgcolor="gray">
<th colspan="5" align="center"><s:text name="priorIncidentTab" /></th>
</tr>
<tr bgcolor="black">
<th><s:text name="date" /></th>
<th><s:text name="reason" /></th>
<th><s:text name="warningInd" /></th>
<th><s:text name="warningDate" /></th>
<th><s:text name="warningDesc" /></th>
</tr>
</thead>
<tbody>
<s:iterator value="claimData.priorIncidents" var="priorIncident" status="status">
<tr>
<s:hidden name="claimData.priorIncidents[%{#status.index}].oid" />
<td><s:textfield theme="simple" name="claimData.priorIncidents[%{#status.index}].incidentDate" id="incidentDate1"/></td>
<td><s:textfield theme="simple" name="claimData.priorIncidents[%{#status.index}].incidentReason" id="incidentReason1"/></td>
<td>
<s:select headerKey="" headerValue="Select" list="#{'Y':'Yes', 'N':'No'}" theme="simple" name="claimData.priorIncidents[%{#status.index}].hasWarning" id="hasWarning1"/>
</td>
<td><s:textfield theme="simple" name="claimData.priorIncidents[%{#status.index}].warningDate" id="warningDate1"/></td>
<td><s:textfield theme="simple" name="claimData.priorIncidents[%{#status.index}].warningDesc" id="warningDesc1"/></td>
</tr>
</s:iterator>
</tbody>
</table>
<td><a href="#" id="add" onclick="MyFunction(%{#status.index})">Add</a></td>
<td><a href="#" id="delete">Delete</a></td>
当我单击添加链接(不在迭代器内)时,我应该能够将索引值传递给一些 Javascript 函数吗?由于我是 JS 新手,有人可以帮忙吗?任何答案都非常感谢?