У меня есть вид, как показано ниже
@using (Html.BeginForm("SubmitSelected", "Costumer", FormMethod.Post, new { id = "form-Costumer", enctype = "multipart/form-data", name = "myform" }))
{
<input type="checkbox" id="checkall" /><span>Check All</span>
<div id="checkboxes">
<table class="table table-bordered">
<thead>
<tr>
<th>
Select //this is from the class where datatype is bool
</th>
<th>
ContactNumber
</th>
<th>
ConsumerName
</th>
</tr>
</thead>
@Html.EditorFor(model => model.transaksiSelectionViewModel.Transactions)
</table>
</div>
<div class="form-group">
@Html.Label("Total Checked")
<div class="col-sm-10">
<input type="text" id="total" class="form-control" />//the result of the number checked here
</div>
</div>
}
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
<script type="text/javascript">
function toggleChecked(status) {
$("#checkboxes input").each(function () {
// Set the checked status of each to match the
// checked status of the check all checkbox:
$(this).prop("checked", status);
});
}
$(document).ready(function () {
//Set the default value of the global checkbox to true:
$("#checkall").prop('checked', false);
// Attach the call to toggleChecked to the
// click event of the global checkbox:
$("#checkall").click(function () {
var status = $("#checkall").prop('checked');
toggleChecked(status);
});
});
</script>
}
Приведенный выше скрипт запускается только для проверки всех флажков в каждой строке.
и я хочу создать функцию для подсчета количества флажков, которые были отмечены, результаты находятся в текстовом поле (Всего проверено).
Я пытался, но это не сработало. Пожалуйста, помогите:)