使用Struts2中的单选按钮检测选定的表行

时间:2013-11-05 07:16:29

标签: java struts2

我想在struts2应用程序的每一行表格中添加单选按钮。然后单击单选按钮并知道所选行。我该如何定义它?这是我的struts2表

     <table>
       <tbody>
            <s:iterator var="list" value="toolSearchForm.toolInfoList">
                <tr>
                    <td>
                        <s:radio name="toolSearchForm.selectedCheckValue" list="checkValue"/>
                    </td>
                    <td><s:property value="categoryName" /></td>
                    <td><s:property value="toolName" /></td>
                    <td><s:property value="version" /></td>
                    <td><s:property value="updateDate" /></td>
                </tr>
            </s:iterator>
        </tbody>
    </table>

1 个答案:

答案 0 :(得分:0)

将id属性添加到行

 <tr id="row__%{#list.index}">

所以你的第一行的id为row_0,第二行为row_1,依此类推

单击单击按钮上的

传递索引

 <s:radio id="check_%{#list.index}" onclick="selectRadio(%{#list.index})" name="toolSearchForm.selectedCheckValue" list="checkValue"/>

在javascript中有这个功能

function selectRadio(rowIdIndex){
//get the row element using the index value
 var rowElement = document.getElementById("row_" + rowIdIndex);
//remove the element or hide the element as per your requirement
}
相关问题