Boolean

Started by sinus, August 15, 2017, 09:35:11 AM

Previous topic - Next topic

sinus

Hi

sorry, a quck question, to be honest, I have researched, but not that long.

In JS/HTML I have different types, like

type="text"
type="number"

What must I write, if the attribute-field is a "yes/no" (boolean)?
Best wishes from Switzerland! :-)
Markus

Mario

"Must write" where? Are you calling an endpoint?
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

sinus

Quote from: Mario on August 15, 2017, 11:53:40 AM
"Must write" where? Are you calling an endpoint?

Sorry, Mario,
I will write it better... but must now to the doctor, nothing special, but a check.  :D
Best wishes from Switzerland! :-)
Markus

Jingo

Hi Markus - so booleans in Javascript are just results that are either True or False...  you really don't need to define them per say but you can initialize the variable if desired like this:

var x = false;

When you check a boolean variable - the result of true or false is then validated using normal if/then/else logic...

Good luck!


thrinn

Markus,
remembering the Attribute Calculator app and some of you early screenshots, I assume what you want is to display some yes/no attribute in the form and be able to change it there, like other attribute values.
With regard to you question here: I think what you mean is the type of HTML input elements. For boolean values, a checkbox is a good representation on screen. The corresponding input type is also called "checkbox".

I just added a boolean example attribute to the Attribute Calculator App. You can find there also some information on how to read and write such an attribute. I will upload the new version to the corresponding app thread.
Thorsten
Win 10 / 64, IMatch 2018, IMA

sinus

Mario, Andy and Thorsten

Thanks a lot for all your input.
It is really a good feeling, becomes help, even is in this case my question was a bit "foggy".

Well, Thorsten hit the nail on the head (we say so in Switzerland, den Nagel auf den Kopf getroffen), I use this for a field in the attributes, what I forgot to mention, when Thorsten created the script.

I had not thougth, that Thorsten would jump in ... and he did even an update for this with an explanation.
Thanks really, I will go and try, but I am sure, it works and I can use this.

It is surprising for me, what can be done all with JS and Mario has pointed out somewhere, that the possibilities for JS are almost endless. "Lerning" JS, I do very very small steps, but nevertheless I lern something.
Thanks!

Best wishes from Switzerland! :-)
Markus