I am creating a survey in qualtrics. I created one block and used loop and merge. In each iteration, one image will be loaded and shown using javascript. The first image appears correctly. But from the second iteration, the images start disappearing. It can be seen that the images are loaded, since I can see them just for one moment when the question is being loaded, but then the image disappears.
How can I fix this problem? What I am doing wrong?
Below is my code:
Qualtrics.SurveyEngine.addOnload(function()
{
var count = Number("${e://Field/count}");
var dirs = ["sensitive-text", "sensitive-notext", "nonsensitive-text", "nonsensitive-notext"]
var seq = "${e://Field/sequence}";
curStr = seq.split(",")[count]
cur = Number(curStr)
dir = dirs[0];
if (cur >= 100 && cur<200)
{
dir = dirs[1];
}
else if (cur >= 200 && cur < 300)
{
dir = dirs[2];
}
else if (cur>=300 )
{
dir = dirs[3];
}
path = "https://juhu.soic.indiana.edu/rakhasan/picshare/" + dir+"/"+curStr+".jpg";
var img = document.getElementById("img");
img.src=path;
img.style.display = 'block'
img.style.height = '1000px'
img.style.width="700px"
Qualtrics.SurveyEngine.setEmbeddedData("count", count+1) ;
});
Seq
is an embedded data field which is randomized for each trial.