About this article
This article explains what the And() or Or() operators are and provide examples of how they can be used with the binding syntax in smart templates.
- What is the And() operator?
- And() operator examples
- What is the Or() operator?
- Or() operator examples
|
Prerequisites
|
What is the And() operator?
And() is an operator that takes many True/False statements as arguments and returns True when all the arguments are True, and returns False if at least one of the arguments is False.
And() logic
Syntax | {{And(True/False, True/False, True/False, ...)}} |
Output | True/False |
And() operator examples
Example 1
Using the And() operator together with IfElse() to set the visibility of a smart field based on the value of three checkbox questions originating from the response form.
Binding | {{IfElse(And(Form.Checkbox1, Form.Checkbox2, Form.Checkbox3), VisibilityType.Visible, VisibilityType.Hidden)}} | |
Input |
Form.Checkbox1 = "☑" Form.Checkbox2 = "☑" Form.Checkbox3 = "☑" |
Form.Checkbox1 = "☐" Form.Checkbox2 = "☑" Form.Checkbox3 = "☑" |
Condition |
True |
False |
Output | Visible text | Hidden text |
Example 2
Using the And() operator together with IfElse()and Equals() to set the visibility of a smart field based on the value of three text questions originating from the response form.
Binding | {{IfElse(And(Equals(Form.Question1, ""), Equals(Form.Question2, ""), Equals(Form.Question3, "")), VisibilityType.Hidden, VisibilityType.Visible)}} | |
Input |
Form.Question1 = "" Form.Question2 = "" Form.Question3 = "" |
Form.Question1 = "" Form.Question2 = "Hello world" Form.Question3 = "" |
Condition |
True |
False |
Output | Hidden text | Visible text |
What is the Or() operator?
Or() is an operator that takes many True/False statements as arguments and returns True when at least one of the arguments is True, and returns False if all the arguments are False.
Or() logic
Syntax | {{Or(True/False, True/False, True/False, ...)}} |
Output | True/False |
Or() operator examples
Example 1
Using the Or() operator together with IfElse() to set the visibility of a smart field based on the value of three checkbox questions originating from the response form.
Binding | {{IfElse(Or(Form.Checkbox1, Form.Checkbox2, Form.Checkbox3), VisibilityType.Visible, VisibilityType.Hidden)}} | ||
Input |
Form.Checkbox1 = "☑" Form.Checkbox2 = "☑" Form.Checkbox3 = "☑" |
Form.Checkbox1 = "☐" Form.Checkbox2 = "☑" Form.Checkbox3 = "☑" |
Form.Checkbox1 = "☐" Form.Checkbox2 = "☐" Form.Checkbox3 = "☐" |
Condition | True | True | False |
Output | Visible text | Visible text | Hidden text |
Example 2
Using the Or() operator together with IfElse() and Equals() to set the visibility of a smart field based on the value of three text questions originating from the response form.
Binding | {{IfElse(Or(Equals(Form.Question1, ""), Equals(Form.Question2, ""), Equals(Form.Question3, "")), VisibilityType.Hidden, VisibilityType.Visible)}} | ||
Input |
Form.Question1 = "" Form.Question2 = "" Form.Question3 = "" |
Form.Question1 = "" Form.Question2 = "B" Form.Question3 = "" |
Form.Question1 = "A" Form.Question2 = "B" Form.Question3 = "C" |
Condition | True | True | False |
Output | Hidden text | Hidden text | Visible text |
Related articles
Comments
Article is closed for comments.