我有一张带有一些复选框的表格,我需要在每次选择1时进行计数。我有两行,我必须分别计算每一行。
以下是复选框:
{!! Form::checkbox('dente[]', $dente->id, null, ['class'=>'denteCheck-up'] ) !!}
{!! Form::checkbox('dente[]', $dente->id, null, ['class'=>'denteCheck-down'] ) !!}
目标始终是选择1,它实时计算并将结果放在此处:
<td id="count_dentes_up"></td>
<td id="count_dentes_down"></td>
为此,感谢这个社区用户的帮助,我使用了以下jquery代码:
$('.denteCheck-up').change(function() {
$('#count_dentes_up').text($('.denteCheck-up:checked').length);
});
$('.denteCheck-down').change(function() {
$('#count_dentes_down').text($('.denteCheck-down:checked').length);
});
问题是,在代码片段中,它工作得很好,但我根本无法工作。为了帮助我使用Laravel 5.4,我将合并以下脚本:
{{-- Scripts --}}
{{-- Bootstrap JS Library File--}}
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js" integrity="sha384-vFJXuSJphROIrBnz7yo7oB41mKfc8JzQZiCq4NCceLEaO4IHwicKwpJf9c9IpFgh" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js" integrity="sha384-alpBpkh1PFOepccYVYDB4do5UnbKysX5WZXm3XxPqe5iKTfUKjNkCk9SaVuEZflJ" crossorigin="anonymous"></script>
{{-- jQuery Charts --}}
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.4.0/Chart.min.js"></script>
{{-- Js Project file --}}
<script src="{{asset('js/script.js')}}"></script>
{{-- Datepiker --}}
<script src="{{asset('js/bootstrap-datepicker.min.js')}}"></script>
{{-- jQuery-ui Library File --}}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>