Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

If/Then Statement Logic Check

Guest
Feb 05, 2016 Feb 05, 2016

Can someone double-check my code?

I want Question2e to be UNCHECKED until all questions A-D are answered... If Yes (or 0) is indicated in any of the answers, then I need Question2e to be answered as Yes (0).  If questions A-D are all no, then No (or 1) can be answered for Question2e

What am I missing?

var f = this.getField("Question2a");

var g = this.getField("Question2b");

var h = this.getField("Question2c");

var i = this.getField("Question2d");

var j = this.getField("Question2e");

// test the field CheckBoxFirst to see if it is checked - '1' checks whether the checkboxes with 'No' Exports are checked

// true = checked box, false = don't check the box

  

if(f.isBoxChecked(0,true) || g.isBoxChecked(0,true) || h.isBoxChecked(0,true) || i.isBoxChecked(0,true)) // Check if any 'Yes' boxes are checked

    j.checkThisBox(0,true);                        // Tells the 'Yes' checkbox to be checked

if(f.isBoxChecked(1,true) && g.isBoxChecked(1,true) && h.isBoxChecked(1,true) && i.isBoxChecked(1,true)) // Check if all 'No' boxes are checked

    j.checkThisBox(1,true);                        // Tells the 'No' checkbox to be checked

else                                              

    j.checkThisBox(1,false);                          // tell box series 'Yes' to check itself

TOPICS
Acrobat SDK and JavaScript
554
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 06, 2016 Feb 06, 2016

The second part of your code makes the first part useless.

So either drop the first if-condition or the else clause of the second.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Feb 06, 2016 Feb 06, 2016
LATEST

I took away the else statement at the end and it 99% works.  Is there a way I can have the Question2e box uncheck if either no boxes are checked or only some of them are checked?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines