我在违规表中有score
字段。而且我有很多复选框。当我选中thed chechboxs时,总分数是用ajax收集的。
<div id="collapse6" class="panel-collapse collapse">
<div class="panel-body">
<div class="table-responsive">
<table class="table table-bordered">
@foreach($infractions as $infraction)
<tr>
<th>{{ $infraction->title }}</th>
<td>
<input type="hidden" name="infractions[{{ $infraction->id }}]" value="0" >
<input type="checkbox" value="1" onclick="{{ $infraction->score }}" name="infractions[{{ $infraction->id }}]" data-toggle="toggle">
</td>
</tr>
@endforeach
</table>
</div>
<div class="text-right"> Totlal
<span id="total">
</span>
</div>
</div>
</div>
Ajax
function scorePlus (id)
{
// var value = parseInt(document.getElementById('num'+id).value, 10);
value = isNaN(value) ? 0 : value;
value++;
document.getElementById('total').value = value;
}