Loops

Loops in your survey allow you to iterate over the same question or set of questions multiple times depending on the answers given by your respondents. There are three types of loops that you can create, and only certain question types will allow certain types of loops. To create a loop, you will need to visit the Survey Logic section within your survey.

Numbered Reverse Loops

Numbered reverse loops can be created using a Choose One Answer or Single Answer Menu question as the trigger. The questions that appear in a numbered reverse loop will always be shown to respondents at least once. Then, depending on how they respond to the trigger question, may be shown again. For example, let's say you have the following set of questions:

In order to allow the user to enter as many past jobs as they would like, you can create a loop. In the loop editor you would set the trigger question to question #6 (Enter Another Employer) and the trigger answer to "Yes". You will then be prompted for the start of the loop, which must come before the trigger in a reverse loop situation. You would select question #2 as the start of the loop (Former Employer Name) and then add the loop to your survey. Once you add this loop, anytime a user takes the survey and answers "Yes" to "Enter Another Employer?", questions 2 through 6 will be duplicated within the survey, allowing the user to answer those questions again.

Whether a page is marked as part of a reverse loop depends on several things. Any pages added specifically for the reverse loop during the response or that are embedded fully within the loop will be considered to be part of the loop (and you can therefore use custom template functions such as loopCount within them. Otherwise, if you have questions on the same page as your reverse numbered loop that are not part of the reversed numbered loop, then that page will not be marked as part of the loop and functions like loopCount may return 0 or even the loopCount of an outer loop. This can be confusing and therefore, it is best to keep your reverse loops fully contained on their own pages without any other questions that are not part of the loop.

Numbered Forward Loops

Numbered forward loops can be created using a Single Text Field or Text Field List as the trigger. The questions that are contained with a numbered forward loop are then shown to the respondent the number of times requested by that respondent. Taking an example similar to our numbered reverse loop, let's say your survey now looks like:

Assuming you want to collect the employment history for each job they have had in the past 10 years, you can now setup a loop that will do just that. In the loop editor you would set the trigger question to question #2 (Number of jobs...). Had this been a Text Field List question type, you would also have to specify a trigger answer to let the survey software know which answer field will contain the number of loops. You will then set the starting (question #3) and ending (question #6) point of the loop, which both must come on a page after the trigger, since this is a forward loop. When a respondent takes the survey, if they enter a value of 3 into question #2, they will then be presented with the employment history section 3 different times.

Named Forward Loops

Named forward loops are created using Choose Multiple Answers or Multiple Answer Menu question types as the trigger. These loops will iterate over a set of questions for each answer a respondent has selected in the trigger. For example, let's assume your survey looks like:

  • Page Contact Information
    1. Text Field List Name & Email Address
    2. Multiple Answers Which email services have you used?
      Answers: Hotmail, Yahoo!, Gmail
  • Page Please tell us about your experience with [% loopResponse %]:
    1. One Answer per Row Rate the following features: (Ease of use, Availability, etc...)
    2. Choose One Answer Would you recommend this site to a friend? (Yes/No)
  • Page Another page in your survey...

To create a named forward loop here, you would go to the loop editor in your survey logic and select question #2 as your trigger. You can then select all of the answers as your trigger answers (if you do not want specific answers to create a loop, such as "Other", do not select them). You would then specify the start (question #3) and end (question #4) of your loop. These two questions would then be shown for each email service selected by the respondent. The [% loopResponse %] tag would replace the name of the selected answer, so they know which service they are rating.