Please tell me how you can when choosing a checkbox to take their value and add a button to the onclick through a space, and when you remove a certain checkbox, its value was removed
<div class="products-cont"> <div class="products"> <input id="product-1" type="checkbox" name="checkboxlist" value="add('1');"> <input id="product-2" type="checkbox" name="checkboxlist" value="add('2');"> <input id="product-3" type="checkbox" name="checkboxlist" value="add('3');"> <input id="product-4" type="checkbox" name="checkboxlist" value="add('4');"> </div> <div class="btn-cont"> <button type="button" class="btn btn-main prod-btn-1" onclick="add('8');">Добавить</button> </div> </div> I would be very grateful for any help.