avatar
use radio button checkbox Javascript

• The first step is to manually generate a sample HTML. At the same time, we will add radio button checkbox.

<div class="form-group">
    <div id="option_no_sequence" class="d-flex align-items-center mt-2">
        <input type="radio" hidden name="delete_type" id="delete_type1" value="0" checked>
        <label class="form-check-label ml-1" for="delete_type1">
            Delete Option 1
        </label>
    </div>
    <div id="option_sequence" class="d-flex align-items-center mt-2">
        <input type="radio" hidden name="delete_type" id="delete_type2" value="1">
        <label class="form-check-label ml-1 w-100" for="delete_type2">
            Delete Option 2
        </label>
    </div>
</div>

• Handle JavaScript to set up the update and removal of checked properties for the radio button checkboxes.

$(document).on('show.bs.modal','#sample_modal', function (event) {
  
    let radioElement1 = document.getElementById("delete_type1");
    let radioElement2 = document.getElementById("delete_type2");

    if (<Condition>) {
        radioElement1.checked = true;
        radioElement2.checked = false;
    } else {
        radioElement1.checked = false;
        radioElement2.checked = true;
    }
});
You need to login to do this manipulation!