the idea is this - when choosing a checkbox, the form should be sent

<form name="upsert" id ="myForm" method="POST"> <input type="checkbox" id="slideThree" name="check" <?= $check ?>/> <INPUT TYPE="SUBMIT" VALUE ="Сохранить"> </form> <script> $(document).ready(function () { $("#slideThree").change(function () { $("#myForm").submit(); }); }); </script> 

When you click on the button, the data from the checkbox disappears. when clicking on the checkbox, everything is sent except for the checkbox value

    2 answers 2

    Well, there is such an option.

     <form name="upsert" id ="myForm" method="POST"> <input type="checkbox" id="slideThree" name="check" <?= $check ?>/> <INPUT TYPE="SUBMIT" VALUE ="Сохранить"> </form> <script> $(document).ready(function () { $("#slideThree").on('click', function (e) { e = e.originalEvent; if(e){//Это чтоб в консоль ошибки не лезли e.preventDefault();//Это прекращает стандартное действие e.stopPropagation();//Это прекращает действия последующие после стандартного } $("#myForm").submit(); }); }); </script> 

    And it was easier to put disabled on the checkbox and all)

      if you look here, then generally emulate a click on a submission. more like a hack

      https://stackoverflow.com/questions/6480316/jquery-submit-form-onchange

       $(document).ready(function(){ $('#widgetFieldInput').change(function(){ $('#select_date').click(); }); });