CheckBox Value

Jagjit Saini 106 Reputation points
2021-06-09T05:32:58.713+00:00

Hi

How to save CheckBox Value in a variable

<div class="form-group row">
<label for="IsActive" class="col-sm-2 col-form-label">IsActive</label>
<div class="form-check col-sm-10">
<input type="checkbox" class="form-check-input" id="IsActive" name="IsActive">
</div>
</div>

var objLocation = {
Id: $('#txtId').val().toUpperCase(),
Description: $('#txtDescription').val().toUpperCase(),
};

Thanks

Developer technologies ASP.NET Other
{count} votes

1 answer

Sort by: Most helpful
  1. AgaveJoe 30,126 Reputation points
    2021-06-09T10:15:39.94+00:00

    How to save CheckBox Value in a variable

    The jQuery syntax is exactly the same as you are already using...

    $('#IsActive').val()
    

    The problem is your checkbox design does not have a value attribute.

    <input type="checkbox" class="form-check-input" id="IsActive" name="IsActive" value="MyValue">
    

    Are you actually trying to detect if the IsActive is checked?

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.