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

时间:2022-12-03 07:53:33

I want to get the selected the check box row text values from the row.I'm using jstl tags to display the list of records in page.Please see my code below...

我想从行中选中复选框行文本值。我使用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 class :

java类:

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

Jquery for selectAll

用于selectAll的Jquery

$('#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);
    });
});

1 个解决方案

#1


0  

$('.selectedId:checked').each(function(index, value) {
    // gets row inputs
    var $inputs = $(this).closest('tr').find('input[type="text"]');

    // do something here
});

You can change the find's selector as you need.

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

By the way, you missed a </td> on the last column cell.

顺便说一下,你在最后一个列单元格上错过了 。

#1


0  

$('.selectedId:checked').each(function(index, value) {
    // gets row inputs
    var $inputs = $(this).closest('tr').find('input[type="text"]');

    // do something here
});

You can change the find's selector as you need.

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

By the way, you missed a </td> on the last column cell.

顺便说一下,你在最后一个列单元格上错过了 。