Skip to main content
February 6, 2016
Question

If/Then Statement Logic Check

  • February 6, 2016
  • 1 reply
  • 615 views

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

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
February 6, 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.

February 6, 2016

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?