This question has already been answered:
How can I select or deselect all checkboxes at once, so that if I have already selected some checkboxes, it works correctly, that is, if I have two boxes, then when I click, everything is highlighted without inversion and vice versa?
Code example:
<input id="i1" type="checkbox" name="additional"> <label for="i1">Вариант №1</label> <br> <input id="i2" type="checkbox" name="additional"> <label for="i2">Вариант №2</label> <br> <input id="i3" type="checkbox" name="additional"> <label for="i3">Вариант №3</label> <br> <input id="i4" type="checkbox" name="additional"> <label for="i4">Вариант №4</label> <br> <input id="select_all" type="checkbox"> <label for="select_all">Выбрать / Снять Все</label>
false
with a parameter - Grundy