对不起,我的英语非常不好。当我单击复选框时,应该读取金额,但是当我更改时,页面开始从零开始计数。不保存其他页面, 我无法做到这一点,因此当我更改页面时,他必须记住上一页的检查值。 我已经为此工作了一个月,但我做不到。 有人可以帮我吗?
<div class="row">
<div class="col-sm-5">
<div class="row text-center bg-primary">
<div class="col-md-6">
<b>Unique - <span id="unique"></span></b>
</div>
<div class="col-md-6">
<b>Total - <span id="total"></span></b>
</div>
</div>
<br>
<div class="row text-center">
<table class="table table-condensed table-subscribers-per-discipline">
<thead>
<tr>
<th class="text-center">Select</th>
<th class="text-center">Discipline</th>
<th class="text-center">Count</th>
</tr>
</thead>
<tbody>
<?php
$seriesArray = [];
$seriesTemplate = '["%s", %s]';
foreach ($this->subscribersPerDiscipline as $row) { ?>
<tr>
<td>
<label for="count"></label>
<input onClick="document.getElementById('theSubmitButton').click();" id="count" type="checkbox" data-value="<?= $row['subscribers_per_discipline_count'] ?>" value ="<?= $row['id'] ?>"/>
</td>
<td><?= $row['discipline_name'] ?></td>
<td><?= $row['subscribers_per_discipline_count'] ?></td>
</tr>
<?php } ?>
</tbody>
</table>
<input class="btn btn-success" style="display: none" type="button" id="theSubmitButton" value="Check"/>
</div>
</div>
<?php
foreach ($this->subscribersPerTopDiscipline as $row) {
$series = sprintf(
$seriesTemplate,
$row['discipline_name'] . ' ' . '<strong>' . $row['subscribers_per_discipline_count'] . ' </strong>',
$row['subscribers_per_discipline_count']
);
$seriesArray[] = $series;}
$seriesString = implode(',', $seriesArray);
?>
<script>
var dataStatus = 0;
$('#unique').text(dataStatus);
var dataValue = 0;
$('#total').text(dataValue);
$("#theSubmitButton").click(function(event){
event.preventDefault();
var subscribersPerDiscipline = $("input:checkbox:checked").map(function(){
return $(this).val();
}).get();
var dataStatus = 0;
$('#unique').text(dataStatus);
$.ajax({
url: '<?= $this->url('statistics/user/get-distinct-subscribers-count-per-discipline-json') ?>',
method: "POST",
data: {
subscribers_per_discipline: subscribersPerDiscipline
},
dataType: "json",
success: function(data) {
dataStatus = data['distinctUsersCountByPerDiscipline'];
$('#unique').text(dataStatus);
console.log(dataStatus)
}
});
var dataValue = 0;
$.each($("input[type=checkbox]:checked"), function (k, v){
var val = $(this).data('value');
dataValue = parseFloat(dataValue + val);
});
$('#total').text(dataValue);
});
$(document).ready(function() {
$('.table-subscribers-per-discipline').DataTable({
bInfo: false,
pagingType: 'simple',
bPaginate: true,
bLengthChange: false,
"aaSorting": [ [2, 'desc'] ],
"aoColumns": [
{
"bSortable": false
},
{
"bSortable": true
},
{
"bSortable": true
}
]
});
});