Displaying Different Images in Loop Iterations

Overview

Sometimes we would like to display a big batch of images inside a loop chapter, in a way that a different image is being displayed on each iteration.

Here you can find a sample survey that shows just how to do that:

The sample survey contains a loop chapter that iterates 3 times, and display a different image in each iteration.

You can view the sample survey by importing it into you account. This link shows how to import a survey:

http://support.dooblo.net/entries/22388573-How-to-import-a-survey

Important note: The attachments attached to the sample survey won't be imported along with the survey into your account. So please read this next steps that explain the exact needed procedure, demonstrated in the sample survey:

1. Add the relevant attachments to the survey - Go to the survey's Advanced tab -> Edit Survey Attachment -> New, and choose the image you want to add. This way add all the wanted attachments. In the sample survey there're 3 attachments: "A.jpg", "B.jpg" and "C.jpg.

2. Create the attachment source: Attachment source is a mechanism that allows you to handle attachments dynamically during an interview. An attachment source generates a list of the attachments you want to use then later that list can be associated with a specific question. You can view this link to learn more about attachment source: https://support.dooblo.net/hc/en-us/articles/208295765-How-To-Dynamically-Display-Answer-Images

But please note the differences in the attachment source in the sample survey: 

The "Test" attachment source contains a code that controls the image that will be displayed in each iteration in the loop.

Basically, the code checks the current iteration number the loop is in.

If the iteration is #1 - Display the "A.jpg" image. 

If the iteration is #2 - Display the "B.jpg" image.

else (If the iteration is #3) - Display the "C.jpg" image.

In your script, make sure you use the "list.AddFromAttachment()" function (and not list.Add() like in the HowTo link above...), and change the images names to match your images names.

3. Q3 in the sample survey is the question where we display each image. View these definitions there're in the Advanced tab of this question: 

- AdvanceAfterAttachmnet -> True

- AttachmentSource -> Test (this is the name of the attachment source created in the sample survey)

- DisplayAttachmnetsInBody -> True

 

That's it!

 

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.