lundi 17 octobre 2022

I am trying to pass in a DISABLEDcheckbox value to the controller, but it does not seem to be passed

Below is the code to select all the server

<input type="checkbox" id="all_maintenace" class="checkbox " style="vertical-align: middle;"
 name="all_chkb_maintenace" value=""> Maintenace All </th>

Below is the code to select individually

<input type="checkbox" id="maintenace_" class="checkbox checkbox_maintenace"
 style="vertical-align: middle;" name="chkb_maintenace[]" value=""
 >
<input type="text" name="chkb_all_users[]" value="" hidden>

Below will be the code to disable / freeze the maintenance checkboxes

<input type="checkbox" id="freeze_" class="checkbox checkbox_freeze"
 style="vertical-align: middle;" name="frz_maintenace[]" value="">
<input type="text" name="chkb_all_users_frz[]" value="" hidden>

Below will be the script

$(document).on('click', '#all_maintenace', function() {
          var checkboxes = $('.checkbox_maintenace');
          var chk_value = $('.checkbox_maintenace').val();


          $.each(checkboxes, function(i, v) {
            var disabled = $(v).prop("disabled");
            var checked_length = $(v).is(":checked");

            $(v).prop("checked", $('#all_maintenace').prop("checked"));

            if (disabled && !checked_length) {
              $(v).prop('checked', false); // Unchecks it
            } else if (disabled && checked_length) {
              $(v).prop('checked', true); // Checks it
            }

          });
        });
    $(function() {
          $(".checkbox_freeze").on("change", function() {
            var ticked = $(this).val();
            const checked = this.checked;
            $("#maintenace_"+ticked).attr("disabled", checked)
          });
        });

controller:

$all_user = $request->chkb_all_users;
$selected_user = $request->has('chkb_maintenace') ? $request->chkb_maintenace : [];
$un_selected_user = array_diff($all_user, $selected_user);

So my question is how do i pass the to the controller the checkbox value that i have disabled/freeze, while the other checkboxes that i have not disabled/freeze are passed into the controller




Aucun commentaire:

Enregistrer un commentaire