I’m nearing the completion of my web app, so I’ve been doing a lot of testing. Well, one thing I realized was that the way I’m storing my checkbox value in the database isn’t correct. Here is what I’m doing:
As you can see in the image above, I have a simple checkbox. Elsewhere on the same page, I have “yes” assigned as a number, as such:
Essentially, I have an interactive checkout system that adds or subtracts the total, based off whatever a user chooses. They see their total changing in live time. So, in this case, when they check the box it adds “99” to their total.
Well, this is how I’m storing it in the database:
For some reason, it’s all adding up correctly, however, the “yes/no” value isn’t being stored correctly in the database. When I show if it’s featured or not elsewhere, it doesn’t have the correct “yes/no” value. Sometimes it makes it “featured” even though the box was never checked.
Gotcha, that makes me understand why it’s doing it. Now I have to figure out how to store it as true or false. I can store it statically like this:
But I’m wanting it to store if checked = yes or if it isn’t checked = false.
Side note: It’s pretty funny how this is tripping me up because I have all kinds of equations and functionality that this is seemingly simpler in comparison, but I don’t know how to get around this…
I’m not sure I’m understanding how this works, but I think it works. Its basically saying, when checkbox is checked = “yes” then if left unchecked it’s defaulting to no.
I have the default in the database as no, to re-enforce it.
Yes, empty values (just like nulls in JavaScript) are “falsey”. Empty is a “false” state. Not empty values (a thing of some type actually has a thing of that data type inside of it) are “truthy”. Not empty is a “true” state.
Did I talk about that at all in the “Cool with Boole” video? If not, I guess I should have.
It works like a charm! Thanks again guys and thanks for the in-depth explanation. I truly appreciate your willingness to help. It makes Bubble so much better…