Skip to main content
Inspiring
March 29, 2018
Answered

When does setting a checkbox take effect relative to the associated action ?

  • March 29, 2018
  • 1 reply
  • 1173 views

Hi,

I've got a single checkbox assigned to the field EnableFullScreen.  The JavaScript action that handles the checkbox is as follows:

    if(EnableFullScreen.isBoxChecked(0) == true)

         app.fs.isFullScreen = true;

       else

         app.fs.isFullScreen = false;

The above code is executed on a Mouse Down event.

When the checkbox is set, I want my PDF to be fullscreen.  When the checkbox is not set, I don't want my PDF to be fullscreen.

The code above is doing the opposite of this.  Not checked = fullscreen, checked = not fullscreen.

It is behaving like, when I evaluate isBoxChecked(0), the checkbox isn't actually checked yet.  Hence, my question about when setting a checkbox actually takes effect relative to the code which is executed in response to the Mouse Down event.  If I check a checkbox, should isBoxChecked(0) already be true when I get to the above Mouse Down JavaScript for that checkbox?

Or is there some delay in actually setting the checkbox such that, when the above code is executed, the checkbox won't actually be checked yet?

Thanks for your help with this.

Dave

This topic has been closed for replies.
Correct answer try67

Replace your code with this:

app.fs.isFullScreen = (event.target.value!="Off");

1 reply

Bernd Alheit
Community Expert
Community Expert
March 29, 2018

You test the old value of the checkbox.

DHeadrickAuthor
Inspiring
March 29, 2018

Hi Bernd -- Thanks for your reply.

Your answer certainly explains what's going on.  Is there any way, once I get to my JavaScript action code, to test the current value?


Or do I just need to re-design my code to reflect that I'm testing the old value?  This would be quite trivial, but from a software design perspective, I would rather be testing the current value if I could.  For example, if I test isBoxChecked a SECOND time in my JavaScript action code, would this possibly check the current value?

Thanks again.


Dave

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
March 29, 2018

Replace your code with this:

app.fs.isFullScreen = (event.target.value!="Off");