Accessibility Compliance
SurveyJS libraries meet a variety of WCAG and Section 508 standards. Run AXE® Validation to assess this demo’s accessibility level.

Breakable Loop

Edit in →
Survey Creator

A breakable loop allows respondents to repeat the same set of questions in a loop to add multiple entries. Respondents can exit the loop when they want to, or the loop can end automatically when a certain condition is met. This may happen when a maximum number of entries is reached, a specific value is entered, or a validation rule is triggered. Once the loop ends, the respondent can proceed to the next question or submit the survey.

In SurveyJS Form Library, two question types can be used to create a breakable loop: Dynamic Panel and Dynamic Matrix. Regardless of the question type you choose, the loop can be enabled only if your survey displays one input field per page. To enable this structure, set the questionsOnPageMode property to "inputPerPage" at the survey level.

To implement a breakable loop based on a Dynamic Panel or Dynamic Matrix, follow the steps below:

  1. Configure the repeated questions.
    Define the question configurations in the templateElements array in a Dynamic Panel or columns array in a Dynamic Matrix.

  2. Specify a title pattern.
    Each iteration step displays a title. To customize it, use the templateTitle property in a Dynamic Panel or singleInputTitleTemplate property in a Dynamic Matrix. The title pattern supports text piping from other questions and loop levels.

  3. (Optional) Define conditions for breaking the loop.
    Respondents can stop adding new entries when they want to, but you can specify conditions that end the loop automatically. For example, the maxPanelCount property in a Dynamic Panel and maxRowCount property in a Dynamic Matrix define the maximum number of repeating sections a user can add. This demo sets the maxPanelCount property to 5. If you need a more sophisticated logic for breaking the loop, use triggers.

For a Dynamic Panel code example, refer to the Code tab in this demo. A Dynamic Matrix code example is shown in the Nested Loops demo.

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.