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

时间:2013-12-15 20:18:27

标签: javascript jquery jsp

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

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

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 个答案:

答案 0 :(得分:0)

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

    // do something here
});

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

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

相关问题