## (Survey Logic) Chapter 2 – Entrance (Skip) Rules

**Back to Table Of Contents
Back to Chapter 1 – Overview logic in SurveyToGo
**

**About entrance rules (Also known as skip rules)**

A question or chapter entrance rule control whether that question or that entire chapter is shown or not. When no entrance rule is specified for a question or a chapter, the default behavior of SurveyToGo is to display this question or chapter.

Entrance rules can be based on answers to previous questions or any other expression that you might need. If an entrance rule evaluates as true, the question or chapter will be shown. If it evaluates as false, the question or chapter will not be shown.

**Adding entrance rules**

Adding entrance rules is a very easy process:

- Select the question you wish to add an entrance rule for

- Switch to the “Rules” tab

- Write the relevant entrance rule on the “Entrance rules” text box on the top.

**Sample entrance skip rules**

The following sections are sample snippets that will help you to perform the most common entrance rules tasks.

**(1) Display Q2 only if the answer to Q1 was the first choice
**

**Survey Snippet
**

[Q1]: “What is your favorite color?” [red/green/blue]

[Q2]: “How many cigarettes per day?” [numeric]

**Requirement
**

Display Q2 only if the answer to Q1 was red (the first answer)

**Solution
**

Add the following entrance rule to Q2:

[condition] Answer (1) == 1

**Explanation
**

The entrance rule checks the answer to Q1. If the answer is equal to “1” – which means the first choice: red – the condition evaluates to TRUE, and the question will be shown.

**Survey Snippet
**

[Q1]: “What is your favorite color?” [red/green/blue]

[Q2]: “How are you feeling?” [good/so-so/bad]

[Q3]: “How many cigarettes per day?” [numeric]

**Requirement
**

Display Q3 only if the answer to Q1 was red (the first answer) AND the answer to Q2 was “bad” (the third answer)

**Solution
**

Add the following entrance rule to Q3:

[condition] Answer (1) == 1 && Answer (2) == 3

**Explanation
**

The entrance rule checks the answer to Q1 AND the answer to Q2. Please note the use of the && symbol to indicate a logical AND. If the answer to Q1 is equal to “1” – which means the first choice: red – AND the answer to Q2 is “bad” (the third choice). the condition evaluates to TRUE, and the question will be shown.

**(2) Display Q3 only if the sum of Q1 and Q2 is greater than 12
**

**Survey Snippet
**

[Q1]: “How many dogs to you have?” [numeric]

[Q2]: “How many cats do you have?” [numeric]

[Q3]: “As an owner of more than 12 pets, do you live a healthy life?” [yes/no]

**Requirement
**

Display Q3 only if the sum of Q1 and Q2 is greater than 12.

**Solution
**

Add the following entrance rule to Q3:

[condition] Answer (1) + Answer (2) > 12

**Explanation
**

The entrance rule checks the sum of the answer to Q1 and Q2. If the sum is greater than 12 the condition evaluates to TRUE, and the question will be shown.

**Go To Chapter 3 – Validation Rules
**

**Back to Table Of Contents
**

**Visit us at: http://www.dooblo.net**

Hi,

Similar to “AND” rule, can you please provide the code for “OR” rule?

For instance what to use instead of && if we have to say when “ANY” of 1 or 2?

Thanks!

To indicate logical OR, you write || so for example: 1 || 2

You can learn more about the logic operators here: https://manual.dooblo.net/2011/12/06/how-to-use-basic-scripting-operators/

Great thanks. Also can you tell the code for (not equal)?

If (equal) code is ==

(not equal) code is ?

Thanks!