方法一:
javascript代码:
function checkedChild(obj,index){
var checkBoxs = document.getElementsByName("carId"+index);
if(obj.checked){
for ( var i = 0; i < checkBoxs.length; i++){
checkBoxs[i].checked = true;
}
}else{
for ( var i = 0; i < checkBoxs.length; i++){
checkBoxs[i].checked = false;
}
}
}
方法二:
jQuery代码:
function checkedChild(obj,index){
$("#tr"+ index + " :checkbox").prop("checked", obj.checked);
}
jsp页面:
<c:forEach item="${result}" var = "wb" varStatus="vs">
<tr id="tr${vs.count}">
<td align="center">
<input name="waybillNo" type="checkbox" value="${wb.waybillNo}" onclick="checkedChild(this,'${vs.count}')">
</td>
<td>
<div class="tab_txt">
<ul class="yd_car">
<c:forEach items="${wb.carVOs}" var="car">
<li>
<input type="checkbox" name="carId${vs.count}" value="${car.id}" class="car_class_${vs.index}">
</li>
</c:forEach>
</ul>
</div>
</td>
</tr>
</c:forEach>
版权声明:本文为博主原创文章,未经博主允许不得转载。