L
L
Lavrov952018-05-29 15:33:18
AJAX
Lavrov95, 2018-05-29 15:33:18

How to get the sum of text lines where checkbox is true?

Datatables 1.10,

<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
                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>

$(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
                }
            ]

        });
    });

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question