KNielsen
KNielsen

Reputation: 3

How to get value of Qualtrics Drag & Drop Choice using Javascript

I have what should be a simple answer. I have a drag and drop style multiple choice question on Qualtrics. I have recoded the answers as I wish. I think it assigns to each answer a variable like QID15_1 QID15_2 QID15_3, etc. The outputted data then gives the rank order of that selected option.

So if I ranked them, for example

  1. QID15_3
  2. QID15_1
  3. QID15_2

The value of QID15_3 =1, the value of QID15_1=2, and the value of QID15_2=3.

What is the correct syntax to access these values? I want to set an Embedded Data item with the value of QID15_1, for example (so it should equal 2), but I can't seem to get it correct.

I've tried Qualtrics.SurveyEngine.getSelectedAnswerValue and things like this.

Any help would be appreciated. Thanks!

EDIT: With the help of a friend who knows Java, we figured it out. You can write something like

Qualtrics.SurveyEngine.addOnUnload(function()
{var order=document.getElementById( 'QR~QID15~1' ).getElementsByClassName( 'rank' )[0].innerText;
}

Upvotes: 0

Views: 604

Answers (1)

T. Gibbons
T. Gibbons

Reputation: 5029

You don't need to set an embedded variable in JavaScript. You can just pipe the value wherever you need it (in a subsequent question, in the survey flow, etc.). It would be:

${q://QIDx/ChoiceNumericEntryValue/y}

where x is the question id and y is the choice id.

EDIT: You can assign it to an embedded data variable in the survey flow like this:

edvar = ${q://QIDx/ChoiceNumericEntryValue/y}

Upvotes: 0

Related Questions