Conditional Values determine whether the element containing the conditional statement will be visible. If the expression in the conditional value is evaluated to true at runtime, the element will appear on the form. These conditional values are used to create simple or complex skip logic. (For example, if ‘No’, skip to question 10.) This should not be confused with iFormBuilders "disable" feature. Using the disable feature will prevent the element from being visible on the device regardless of conditional value.
In the example below if the user selects "Other" from the pick-list then a text area will appear below it on the device. When a user selects any other value besides "Other" the element will never appear on the device. This is controlled by the Conditional Value in the Text-Area element.
Data Column Name: reason
For any question you wish to add a conditional, you will be referencing the “data_column_name” of that element.
Remember, data column names must be database friendly:
1) Preferably all lower case
2) Cannot start with a number
Option lists use index values and always start with 0. The two lists below show that each option can be related to an index value.
These are examples of acceptable conditionals:
data_column_name == 1
data_column_name != 1
data_column_name >= 1
data_column_name <= 1
data_column_name > 1
data_column_name < 1
To assign multiple conditionals to one element use the following:
&& = and
|| = or
Hide an Element From View on the Device
Place the following in the Conditional Value:
[data_column_name] >= [pick list number]
[data_column_name] <= [pick list number]
[data_column_name] < [pick list number]
[data_column_name] !> [pick list number]
[data_column_name1] == [pick list value] II [data_column_name2] == [pick list value] - This statement will evaluate both conditions separately and show the element if either are true.
To have an element show if a particular choice is selected you would use the following conditional:
((data_column_name & parseInt("00001", 2)) == parseInt("00001", 2 ))
This is saying show this element if the 5th choice in a multi-select is chosen.
If you want to have an “Other” choice as the last option in a multi-select or want to put a conditional on the last option the conditional logic would be
((data_column_name & 1) == 1)
***This says we only care if the last bit is on, and not care about any other bits. For more information about bitwise operation, look
*Multi-Select Conditional Example*
Conditional Logic can be applied to a Text and a Number Elements. Using Conditional value in a text element is very similar to that of a Pick List. The main difference is you are using a String of Text enclosed in "Quotes" instead of the Index of the option in the Option List.
Lets say we have the following scenario. There are two Elements, a Text Element and a Label Element. If the user types in "joe" in the text element the label will appear and show the text to the user on the form. If the user enters any other name besides "joe" the label will not appear.
Data Column Name: name
NumberUsing conditional logic with a Number Element is done the same way as using a Pick List.
In this example we have two elements, a number and a text. If the number entered in the number element is greater than or equal to 33 then the temperature is to high and the text element will appear prompting the user to enter a reason for their temperature being to high.
Data Column Name: temperature
Label: Reason for High Temperature