<?php
echo '<input id="checkAll" type="checkbox" onclick="full()" id="checkch" name="checkch" checked /><span name="noprint"><label for="checkAll">'.CHECKORNOT.'</label></span>';
echo <<<JS
<script>
document.getElementById('checkAll').addEventListener('click', function() {

    const elevs = document.querySelectorAll('#elev input[type="checkbox"]');

    elevs.forEach(cb => {
        cb.checked = this.checked;
    });

});
</script>
JS;
$stmt = $pdo->query("
    SELECT DISTINCT division
    FROM {$prefix}_eleves
    WHERE categ = 1
      AND division IS NOT NULL
      AND division <> ''
    ORDER BY division
");

while ($liste = $stmt->fetch(PDO::FETCH_ASSOC)) {

    echo '<option value="'.htmlspecialchars($liste['division'], ENT_QUOTES, 'UTF-8').'">'
        .htmlspecialchars($liste['division'], ENT_QUOTES, 'UTF-8').
        '</option>';
}
echo '</select></div></p></div>
<div id=\'divselect\' style=\'display:inline\'>

</div>';
echo <<<JS
<script>
function nb() {

    const checkall = document.getElementById('checkAll');

    const bud = checkall.checked ? 1 : 0;

    const nbDynEle =
        document.querySelectorAll('input[type="checkbox"]:checked').length
        - bud;

    document.getElementById('NbEle').textContent = nbDynEle;
}

function full() {

    const checkall = document.getElementById('checkAll');
    const nbEle = document.getElementById('NbEle');

    if (checkall.checked) {
        nbEle.textContent = nbEle.getAttribute('data-total');
    } else {
        nbEle.textContent = '0';
    }
}
</script>
JS;
?>