Documentation Docs
Documentation Docs

Branching Logic

About Branching Logic

Branching logic, also known as branch logic or form branching, refers to the practice of designing forms that allows you to direct respondents along different conditional paths based on their responses to preceding questions. With branching logic in place, your form can automatically skip irrelevant questions, reveal or hide certain sections, or even prompt a respondent to the survey completion page. This dynamic approach enables forms to adapt to individual inputs and ensures that respondents are presented with only the most relevant content, thereby increasing completion rates and data accuracy.

For example, consider a customer satisfaction survey for a software product. If a respondent indicates that they are satisfied with the product's performance, branching logic might direct them to a follow-up question asking for additional feedback. However, if the respondent expresses dissatisfaction, the logic might skip the follow-up question and instead prompt them to indicate specific areas of improvement.

Types of Branching Logic

Skip Logic

Skip logic is a form of branching that allows respondents to skip certain questions or sections based on their responses to previous questions. For instance, if a respondent indicates they do not own a car, skip logic might bypass questions related to car ownership and proceed to the next relevant section.

Show/Hide Logic

Show/hide logic, also known as display logic, involves revealing or concealing specific questions or sections based on predefined conditions. For example, if a respondent selects "Yes" to a question about owning a pet, show/hide logic might display additional questions related to pet ownership while hiding them if the respondent selects "No".

Complete Survey Logic

In more complex scenarios, branching logic can direct respondents to the "Thank You" page based on how they responded to a trigger question. For example, if a respondent answers "Yes" to a question about experiencing a particular issue, they might be directed to a follow-up section with more detailed questions about that issue. On the other hand, if they answer "No", they might be directed to the survey completion page because all further questions are not relevant to them due to the absence of any encountered issue.

How to Set Up Branching Logic

Skip to Question

To guide a respondent to a specific question further down the line based on their response to a current question, you can implement an expression-based event called "trigger". When the expression evaluates to true, the trigger initiates an action. One such trigger type is "Skip to question". It takes a respondent to a target question.

To set up branching logic that redirects a respondent to a specific form question, follow these steps:

  1. In the top right corner of the Property Grid, select Survey to switch to the survey-level settings.
  2. Under Conditions, locate a subsection called Triggers and click the Plus icon to add a new trigger.
  3. In the trigger drop-down menu, select Skip to question. Survey Creator: How to implement "skip to question" logic, part 1
  4. Click the Pen icon to expand the trigger settings.
  5. Use one of the following ways to specify an expression that, when evaluates to true, will take a respondent to the target question (the destination you want to direct a respondent to).
    • Enter the expression in the Expression field.
    • Click the Magic wand icon to open a popup and build the expression using a GUI. Click Apply when you finish.
  6. Select a target question using the drop-down menu of the Question to skip to property. Survey Creator: How to implement "skip to question" logic, part 2

Show/Hide Questions

The simplest way to incorporate branching logic in a form is by displaying certain questions to some of your respondents while hiding them from others based on their answers. This approach is particularly convenient when you need to target specific form elements. With SurveyJS, you can set up display logic on individual questions, sections (in SurveyJS referred to as "panels"), or the entire page.

To create a conditional rule that determines the visibility of a question, panel, or page, do the following:

  1. Select the dependent element you want to dynamically hide.
  2. Expand its Conditions category in the Property Grid and locate the Make the question/panel/page visible if property.
  3. Click the Magic wand icon on the right of the property. This action opens a popup with a GUI for setting up display logic.
  4. In the popup, select the trigger element ID (its Question name property value).
  5. Select a condition from the drop-down menu: Empty, Not Empty, Equals, Does not equal, Any of, Greater than, Less than, Greater than or equals to, or Less than or equals to.
  6. Type in or select the triggering answer.
  7. Click Apply.
Survey Creator: How to implement question display logic

Complete Survey

To automatically complete a survey based on a user response, perform the following steps:

  1. In the top right corner of the Property Grid, select Survey to switch to the survey-level settings.
  2. Under Conditions, locate a subsection called Triggers and click the Plus icon to add a new trigger.
  3. In the trigger drop-down menu, select Complete survey. Survey Creator: How to implement "complete survey" logic, part 1
  4. Click the Pen icon to expand the trigger settings.
  5. Use one of the following ways to specify an expression that, when evaluates to true, will activate survey completion.
    • Enter the expression in the Expression field.
    • Click the Magic wand icon to open a popup and build the expression using a GUI. Click Apply when you finish. Survey Creator: How to implement "complete survey" logic, part 2

Graphical User Interface for Conditional Forms

SurveyJS Form Builder offers a user-friendly Logic tab and Conditions sections within the Property Grid for all form elements. These features allow users with diverse technical expertise to effortlessly configure conditional logic via a graphical user interface (GUI). The Logic tab consolidates all conditional rules created in the individual Conditions sections of the Property Grid. Within the Logic tab, users can implement all available types of form branching, including "Skip to question", "Complete survey", and "Show/Hide question".

Survey Creator: Condition list in the Logic tab

See Also

Send feedback to the SurveyJS team

Need help? Visit our support page

Copyright © 2024 Devsoft Baltic OÜ. All rights reserved.

Your cookie settings

We use cookies on our site to make your browsing experience more convenient and personal. In some cases, they are essential to making the site work properly. By clicking "Accept All", you consent to the use of all cookies in accordance with our Terms of Use & Privacy Statement. However, you may visit "Cookie settings" to provide a controlled consent.

Your renewal subscription expires soon.

Since the license is perpetual, you will still have permanent access to the product versions released within the first 12 month of the original purchase date.

If you wish to continue receiving technical support from our Help Desk specialists and maintain access to the latest product updates, make sure to renew your subscription by clicking the "Renew" button below.

Your renewal subscription has expired.

Since the license is perpetual, you will still have permanent access to the product versions released within the first 12 month of the original purchase date.

If you wish to continue receiving technical support from our Help Desk specialists and maintain access to the latest product updates, make sure to renew your subscription by clicking the "Renew" button below.