How To Dynamically Display Answer Images based on an answer of a question

Overview

Part of the SurveyToGo features is the ability to attach and display images as answers. One way is to assign images manually to each answer, as you can learn in this link:http://support.dooblo.net/entries/22814656-How-to-add-images-to-Answers-and-Topics

In this How To, you’ll learn a dynamic way to assign and display images as answers based on an answer of a question.

 

Step 1: Add the wanted images to the survey

All images used, need to be uploaded to the survey. To upload images files to the survey, go to the survey’s advanced tab, click on the “Edit survey attachments” link and add your files through the “New” button:

Step 2: Create Attachment Source

 For example let’s assume the question I would like to base my answers images has the following 3 answers:


Then these are the steps you should follow:

  1. Go to the survey Advanced tab and open the “Edit attachment source” link:

  2.  Click on the “+” button to add the attachment source, and name it as you will. To add images to the attachment source, you need to use this code:

    list.AddFromAttachment(“ImageName”, <Answer/Topic>Index);

    “ImageName” should be replaced with a name of an image you uploaded to the survey.
    For each answer you have in the question you should have a part in your script which adds the images for this answers.
    In each part, each image you’ll add to the attachment source will be displayed for each answer, according to the order you added in. For example, in the screen shot below, you see the “Country” attachment source, where we have 3 “if” statements and in each of them three images are added. This means that in the question I’ll use this attachment source, the corresponding Coca Cola image will be displayed in answer index 1, the corresponding Sprite image will be displayed in answer index 2, and the Fanta image will be displayed in answer index 3.



    When you finish with the attachment source, click “OK”.

Step 3: Assign the attachment source to the question

Go to the question’s Advanced tab, and choose the relevant attachment source to be defined for the “AnswerAttachmentSource” property:


 

The attached sample survey will show you an example of the method described above.

In order to test the sample, you’ll need to perform the following:

 

That’s it!

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

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.