question

JagjitSaini-0360 avatar image
0 Votes"
JagjitSaini-0360 asked AgaveJoe answered

CheckBox Value

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

dotnet-aspnet-mvc
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @JagjitSaini-0360 ,
What do you mean?Why you need to save checkbox value in a variable? Do you have many checkbox? Could you post more details of your requirement to us?
If you have only one checkbox,you could do like this:
103748-capture.png
Best regards,
Yijing Sun

0 Votes 0 ·
capture.png (22.9 KiB)

1 Answer

AgaveJoe avatar image
0 Votes"
AgaveJoe answered

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?






5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.