Only display this question if determines if the question should appear, Jump to allows you to skip the question.
The Actions and Logic tools provide the ability to Display.. and/or Jump to options which can be used for applying very sophisticated logic to the behavior of your form.
When to Use Display Logic vs. Jump Logic
Both Display and Jump logic can be used to control the navigation of a form. But there are some very noticeable differences in how the work in particular situations.
- Display the tools
- When you want to control if questions are visible or not depending on the condition. Questions with display if logic will be invisible in a form until the display condition is met.
- When what you want to control is a question that will be required. If a question is invisible, doForms does not check its required status. Only after the display condition is met, and the question is displayed, will doForms check the required status.
- Change the flow of the form
- When you wish to jump over large parts of a form using just one condition.
- When you do not need to hide questions (just skip over them)
- When there are no required questions that will be skipped over. Even when skipped over, doForms will evaluate the required status of questions.
In most cases using display if logic is preferable to jump to logic because to the greater control it provided over if a question will be visible and if its required status will be checked.
Jump to if logic: This setting works similarly to Jump to logic, but allows for more complex evaluation, with less than, greater than, less than or equal to, and greater than or equal to operators being supported. Jump to if logic also supports else and else if statements, allowing for one question to potentially jump to several different points in the form depending on the answer.
Adding Jump to Logic
You can apply jump to logic to jump from one question to any other question below it (or to the end of the form). This is done by evaluating the answer to the original question based on a condition, and then jumping to the destination question if that condition is met.
In the example below, the jump to condition can be interpreted as skip to the end of the form if the answer to the current question is A.
You may also use compound jump to logic to evaluate two or more jump conditions using AND/OR logical operators (see section below).
Note that you cannot use jump to logic to create loops. Use Repeatable Sections for looping.
Adding Only display if logic
You can apply only display if logic to ignore a question based on the answer to any question above it. This is done by evaluating the answer to the prior question based on a condition and ignoring the current question if that condition is not met.
In the example below, the only display if condition can be interpreted as if the answer to the media image capture question above was ‘no_media’, then display the current sketch question. Otherwise, the current sketch question would be ignored.
The example below also illustrates how only display if logic can be used to make robust forms that contain alternative questions when a certain type of hardware input is not available. In this example, if the mobile device does not possess a camera, the previous image capture question would have been skipped over automatically, and the value no_media assigned to that image capture question would have been used to trigger the current sketch question as an alternative.
Another useful tactic is to use the not empty operator. The example below would cause the relevance logic to trigger if any one of the answers to the select multiple question is checked. The alternative for achieving this result would be to use the equal operator in multiple compound logic statements (see next section).
You may also use compound only display if logic to evaluate two or more only display if conditions using AND/OR logical operators (see section below).
Compound logic
Both the Jump to logic and Only display if logic features provide the ability to use multiple logical conditions. As an example, suppose you have a building inspection form with the following Select Multiple question:
In a situation where both Basement and Crawlspace are selected, you would like Numeric Question to be displayed where you can enter the percent that is basement.
Then, you might use the compound only display if logic below to specify that the Percent Basement question will only be displayed if Basement and Crawlspace are checked above:
Applying compound logic can be a little bit tricky. Logical operators are evaluated from left to right, and in the following order:
- Evaluate all less than and greater than, next
- Evaluate all equals to, next
- Evaluate all logical AND, next
- Evaluate all logical OR, next.
Below are a few examples which illustrate how certain compound conditions will be interpreted in the doForms mobile app:
Example 1
Under_Structure is equal Basement AND Under_Structure is equal Crawlspace.
Result:
If Under_Structure = Basement only => Percent_Basement is not displayed
If Under_Structure = Basement & Crawlspace => Percent_Basement is displayed
If Under_Structure = Basement & Crawlspace & Slab => Percent_Basement is displayed
If Under_Structure = Basement & Crawlspace & Slab & Hillside => Percent_Basement is displayed
If Under_Structure = Basement & Slab => Percent_Basement is not displayed
If Under_Structure = Basement & Hillside => Percent_Basement is not displayed
Example 2
Under_Structure is equal Basement AND Under_Structure is equal Crawlspace OR Under_Structure is equal Slab
Result:
If Under_Structure = Basement only => Percent_Basement is not displayed
If Under_Structure = Basement & Crawlspace => Percent_Basement is displayed
If Under_Structure = Slab => Percent_Basement is displayed
If Under_Structure = Basement & Slab => Percent_Basement is displayed
If Under_Structure = Basement & Hillside => Percent_Basement is not displayed
If Under_Structure = Basement & Slab & Hillside => Percent_Basement is displayed.
Example 3
Under_Structure is equal Basement AND Under_Structure is equal Crawlspace OR Under_Structure is equal Slab OR Under_Structure is equal Hillside
Result:
If Under_Structure = Basement only => Percent_Basement is not displayed
If Under_Structure = Basement & Crawlspace => Percent_Basement is displayed
If Under_Structure = Basement & Slab => Percent_Basement is displayed
If Under_Structure = Basement & Hillside => Percent_Basement is displayed
If Under_Structure = Slab => Percent_Basement is displayed
If Under_Structure = Hillside => Percent_Basement is displayed
If Under_Structure = Slab & Hillside => Percent_Basement is displayed
Tip: Consider using the Hide field in mobile app property in special text, numeric, date:time and calculation questions to store data values that can be used to trigger display only if or jump logic conditions.