Skip to main content
Participant
September 28, 2023
Answered

Reading the checkbox state

  • September 28, 2023
  • 1 reply
  • 208 views

Hello! I have this code that creates a checkbox in the dialog box:

var initialsCheckbox = checkboxControls.add({ staticLabel: "Initials" });

Then this code checks the status of this checkbox:

if (initialsCheckbox == true)

But, for some reason, the function is always executed with the condition that the checkbox is not checked. What am I doing wrong?

This topic has been closed for replies.
Correct answer vistarmedia@gmail.com

Solved the problem! It turns out that it was necessary to write this line right after the block with the dialog box:

var SelectIni = initialsCheckbox.checkedState;

And check the status of this checkbox like this:

if (SelectIni == true)

Perhaps it will be useful to someone: I found the solution on the example of the code that came with the program. I advise all beginners like me to look at code usage examples there.

1 reply

vistarmedia@gmail.comAuthorCorrect answer
Participant
September 28, 2023

Solved the problem! It turns out that it was necessary to write this line right after the block with the dialog box:

var SelectIni = initialsCheckbox.checkedState;

And check the status of this checkbox like this:

if (SelectIni == true)

Perhaps it will be useful to someone: I found the solution on the example of the code that came with the program. I advise all beginners like me to look at code usage examples there.