Need something like nested if statements


#1

I am filling out a web form from a csv, and on the form some of the check boxes I have to check are hidden until a different box is checked. Lets call that box 1. Box 1 may or may not be checked but if it is, I have to make if then decisions on the boxes that appear. What I thought would work is nested if statements. If box 1 is checked, check box 2 if it’s checked in the csv. But I can’t use nested if statements. I’ve read about labels and gotoif and I think that’s what I need but I can’t put the pieces together for some reason. Any suggestions would be appreciated.


#2

You can use “and” inside the if statement. This follows the Javascript IF syntax.

In this example we check if ${box1} and ${box2} are true. In your case the value of the box1 variable will be the results of your “is box1 checked” test and, for box2 it will be the value from the CSV file .

{
  "Name": "if and",
  "CreationDate": "2019-3-21",
  "Commands": [
    {
      "Command": "store",
      "Target": "true",
      "Value": "box1"
    },
    {
      "Command": "store",
      "Target": "true",
      "Value": "box2"
    },
    {
      "Command": "if",
      "Target": "${box1} &&  ${box2} ",
      "Value": ""
    },
    {
      "Command": "echo",
      "Target": "Both boxes should be checked",
      "Value": "green"
    },
    {
      "Command": "else",
      "Target": "",
      "Value": ""
    },
    {
      "Command": "echo",
      "Target": "do not check box2",
      "Value": "orange"
    },
    {
      "Command": "endif",
      "Target": "",
      "Value": ""
    }
  ]
}

#3

Yep that got it thanks!