动态生成的html的Table中第一列是checkbox,如何判断选择了哪些checkbox,并获得相对应的记录??
function get(){ var print = document.getElementsByName("isprint"); var factorId; for(var i = 0; i < print.length; i++) { if(print[i].checked) { factorId += print[i].value; factorId +=print[i].getAttribute("value"); //两种方法都可以获得相对应的id值 } }}
<table class="grid"> <tfoot></tfoot> <tbody> <tr> <th width="30px" >序号</th> <th>标签要素名称</th> <th>是否起用</th> </tr> <s:iterator value="%{pageDataFactorDef.datals}" id='vo' status='st'> <td align="center"><s:property value="#st.count+(pageDataFactorDef.currentPage-1) * (pageDataFactorDef.pageSize)" /></td> <td>${vo.factorName}</td> <td> <input type="checkbox" name="isprint" id="isprint" value="${vo.factorId}" /> //直接把你要的值放入checkbox内 </td> <td align="center"> </tr> </s:iterator> </tbody> </table>