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.
Does anyone know the solution to this?
Won’t that expression always evaluate to true? It is saying if this checkbox is checked or if this checkbox is not check, then true.
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…
The names are blacked out. They could be different checkboxes. But this question is an absolute hatful of crazy, as I like to say. Pretty interesting.
The part thats blacked out is referring to the same exact check box. Sorry for any confusion.
It’s crazy, haha, but really cool when a user is using it.
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.
Am I correct in my thinking?
Ya, pretty much you got it. The default is fine, and probably the safest, but an empty boolean evaluates to “no”
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…
makes sense and really good to know.
This topic was automatically closed after 70 days. New replies are no longer allowed.