How can I utilize variable embedded data field names in display logic?

BenSSSBenSSS NY, NY, USACommunity Member Qubie ✭

How can I utilize variable embedded data field names in display logic?

I have a loop and merge block, and I would like certain questions to display based on the value of an embedded data field that CHANGES with every loop. Here is my code, which does not work:

Qualtrics.SurveyEngine.addOnload(function()
{
	/*Place your JavaScript here to run when the page loads*/
	var trial = "${lm://CurrentLoopNumber}" - 1;
	var embData = "rating" + trial;
	if (Qualtrics.SurveyEngine.getEmbeddedData(embData) == -1) var display = 5;
        Qualtrics.SurveyEngine.setEmbeddedData( "display", display)

And then in my display logic for the question, I say to show question if embedded data field called "display" is equal to 5.

Basically, I've named my embedded data fields in a systematic way so that they can be differentially accessed on different loops, so I'm not sure why this isn't working. I also have very little javascript experience, so any help would be greatly appreciated!

Answers

Sign In to Comment