繁体   English   中英

如何从行中获取选定的复选框值?

[英]How to get the selected checkbox value from the row?

我想从该行中获取选中的复选框行文本值。我正在使用jstl标签在页面中显示记录列表。请参见下面的代码...

<c:forEach items="${list}" var="product">
<td><input type="text" value='${product.featurename}' name="featurename" readonly="readonly"/></td>
<td><input type="text" value='${product.featureversion}' readonly="readonly"/></td>
<td><input type="text" value='${product.end_date}' readonly="readonly"/></td>
<td><input type="text" value='${product.new_end_date}' class="datepicker" /></td>
<td><input type="checkbox" value='${product.new_end_date}' name="new_end_date" class="selectedId"/>
</c:forEach>

java类:

String[] newenddate = req.getParameterValues("new_end_date");

jQuery的selectAll

$('#selectall').click(function(i, v){
        $('.selectedId').prop('checked', this.checked);
    });

    var checkCount = $('.selectedId').length;
    $('.selectedId').click(function(i, v){
        $('#selectall').prop('checked',$('.selectedId:checked').length  == checkCount);
    });
});
$('.selectedId:checked').each(function(index, value) {
    // gets row inputs
    var $inputs = $(this).closest('tr').find('input[type="text"]');

    // do something here
});

您可以根据需要更改查找的选择器。

顺便说一句,您错过了最后一个列单元格上的</td>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM