Getting wrong checkbox state

Hey Everyone,

I am struggling with a simple checkbox on a form.

When my checkbox is checked, I am getting its state as “false”, and when it is unchecked, I am getting ‘true’. I don’t know what is happening.

image image

This is the code I have:

<label for="Notifyonearlyavailability" class="container-ck" dmx-on:click="datastoreApp.update({$id: 1},{notifyearly: Notifyonearlyavailability.checked})">I want to be notified ......
<input name="Notifyonearlyavailability" type="checkbox" class="custom-control-input" id="Notifyonearlyavailability" checked="" value="1" />
<span class="checkmark"></span></label>

and this to check the state:
<h3>{{datastoreApp.data[0].notifyearly}}</h3>

@Teodor do you have any suggestions here?

Where exactly do you get its state as false?
You can check the state using the checked attribute like:

{{my_checkbox.checked}}

Exactly, I am trying to check its state in a h3 which I displayed in the picture,
First I am storing the state in a datastore component, (Notifyonearlyavailability.checked ) and everytime the user clicks on it the value should get updated, but when it gets updated its showing the wrong value, it shows true, when it should be false and vice versa.

But that’s not how you check the checked state. As I explained it should have .checked at the end of the expression.

Also I don’t really understand what exactly are you trying to do with the onclick event of the label? Maybe If you explain what are you trying to achieve I will be able to help…

I was trying to store the value of the checkbox state in a datastore field because I have a multi step form and I wanted to store the value so that I can use it in other places, but unfortunately it is not working with me, I will just have to connect with the .checked state directly, which is also fine with me.

That is why I had an on click event on the checkbox so that the datastore field of the checkbox would update everytime, however that is not happening accurately, as the datastore is saving the wrong value of the checkbox, as you can see in the image below

image

    <h3>checkbox state = {{Notifyonearlyavailability.checked}}</h3>
<h3> datastore value = {{datastoreApp.data[0].notifyearly}} </h3>