@if(Model.Is_Prefix_Checked == 1) { <div class="row mb-2"> <div> <div class="col-md-1" style='align-content:center;'> <input type="checkbox" class="largerCheckbox" id="Is_Prefix_Checked" name="IsPrefixChecked" checked="checked" > </div> </div> <label class="col-sm-2 col-form-label">Prefix</label> <div class="col-sm-3"> <select asp-for="EmployeePrefix" class="form-control" asp-items="@ViewBag.prefix" > </select> <span asp-validation-for="EmployeePrefix" class="text-danger" ></span> </div> </div> } else { <div class="row mb-2"> <div> <div class="col-md-1" style='align-content:center;'> <input type="checkbox" class="largerCheckbox" id="Is_Prefix_Checked" name="IsPrefixChecked"> </div> </div> <label class="col-sm-2 col-form-label">Prefix</label> <div class="col-sm-3"> <select asp-for="EmployeePrefix" class="form-control" asp-items="@ViewBag.prefix"> </select> <span asp-validation-for="EmployeePrefix" class="text-danger"></span> </div> </div> }
window.onload = function () { func2(); } function func2() { window.onload=function() { const checkBoxes=document.querySelectorAll("input[type='checkbox']"); const checkBoxes = document.querySelectorAll for(var i=0; i < checkBoxes.length; i++) { if (this.checked) { $(this).attr("value", "1"); } else { $(this).attr("value", "0"); } } } } // this is the scrpt for checkbox $(document).on("click", "[type='checkbox']", function (e) { if (this.checked) { $(this).attr("value", "1"); } else { $(this).attr("value", "0"); } });
onload
checkBoxes
@if
else
checked
asp-for
<input type="checkbox" class="largerCheckbox" id="Is_Prefix_Checked" asp-for="@Model.Is_Prefix_Checked">
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)