# Display conditions, basics 2 – And (&&) and Or (||)

 Compatibility: IdSurvey 7 IdSurvey 8 √ √

As we have seen in other articles of this Knowledge Base, IdSurvey can alter standard questionnaire flow with Display conditions and Skip conditions.

In this article we will analyze display conditions with “And” and “Or”.

## Display condition with “And” (&&)

Display conditions with “And” symbol display an element of the questionnaire when all conditions with this symbol are simultaneously true.
The symbol for conditions with “And” is: &&

For example:

Let’s set the following display condition in question Q4

if(Q1==2&&Q2==2&&Q3==1)

In this case question Q4 is displayed only if I selected answer with code “2” to question Q2 and answer “2” at question Q1 and answer “1” at question Q3.
If even one of those condition is not true, question Q4 will not be displayed.
So if in question Q3 I select answer “3”, question Q4 will not be displayed.

## Display condition with “Or” ( || )

Display conditions with “Or”  symbol display an element of the questionnaire when at least one of the conditions with this symbol is true.
The symbol for conditions with is: ||

For example:

Let’s set the following display condition in question Q6

if(Q4==2||Q5==2)

In this case question Q6 is displayed if I select answer with code “2” to question Q4 or answer “2” to question Q5.
You need just one of the conditions specified above to be true for question Q6 to be displayed.

## Utilizzare gli operatori OR e AND nella stessa condizione

You can combine multiple conditions of any level of complexity, also combining both && and || operators.

For example:

Let’s set a hypothetical question Q3 with the following display condition

`if( Q1==99 || ( Q1==1 && Q1==2 ) )`

In this case question Q3 will only be displayed if answer with code “99” was selected at question Q1 or if both the answers “1” and “2” were selected on question Q1.

Please note that the condition `Q1==1 && Q1==2` is in brackets. This is to indicate the order of elaboration. In this specific example the result of the condition will therefore be elaborated with the condition outside the brackets, so that is `Q1==99 || [risultato della sotto condizione]`

Note

• Without brackets, IdSurvey will process AND conditions before OR conditions. Even if we would suggest always using brackets in order to avoid ambiguities of the order of elaboration, the condition of the example above could also be written without brackets.

For more information and examples on display conditions please check other articles of Logic and Filter Conditions in this Knowledge Base.