JavaScript to Call "Div Id" | XM Community
Solved

JavaScript to Call "Div Id"

  • 31 May 2018
  • 1 reply
  • 44 views

Thank you in advance to anyone who offers advice, assistance or a recommendation.

Issue: I've created a Seed Match / Bracket style survey (similar to a sports bracket) for users to identify the top movie that they would like to enter into an overall contest. There are 16 individual movie titles. The user selects their preferred movie in each round, which than advances to the next round.

The method that I have used to perform this within Qualitrics is piped text, since carry-forward logic only works for one-level forward. While the winning movie needs to be 'carried-forward' for 5 rounds (Conference 1, Semi-Finals, Finals, Championship > Winner Declared).

All of the selections are image-based. Each of the images has been re-coded with a Variable Name. Each answer box also includes a text value (see below screenshot)

The flow of my survey works perfectly, however, the reporting is an issue - since when I get to my Championship question - the reporting does not show the variable name of the movie, but, instead the Piped Text id.

This may be confusing so I attached a PDF overview of the flow for reference ("Piped Text Reporting Issue")....
!


So, when looking at a report on the selected answer in the last question (Championship)...instead of seeing the 16 different potential combinations that could have been 'piped' forward. The report table/graph is showing "${q://QID24/ChoiceGroup/SelectedChoices}" or "${q://QID25/ChoiceGroup/SelectedChoices}" as the x axis variables. Counting the number of times the "${q://QID24/ChoiceGroup/SelectedChoices}" is selected. Instead of showing that Movie 1 made it to QID24 and was selected three times, while Movie 5 was only selected once.
"!

Goal: The goal is to be able to count the number of times a movie is selected when represented in the Championship question.

Solution: After speaking with Qualtrics Support and my Company Success Lead. The best suggestion made was to add a "Div ID" to each image than use JavaScript to pull the 'Div ID' into the final report and an embedded data field to translate that id????? (I dont really flow the solution).

But, I did add a 'Div Id" to each Movie image
!

Assistance Being Requested Would anyone be able to help me determine the JavaScript that would be required in the Championship question so that the selected movies DivId is being called and reported on, instead of the piped text variable.


Thank you again!
icon

Best answer by mattyb513 12 July 2018, 04:57

View original

1 reply

Userlevel 6
Badge +6
To access an ID you can use this gist: https://gist.github.com/mattbloomfield/4cbedb3972aeb5ec0169fd6f24e6af51

What it will do is save the selected option as embedded data named "Winner".

I'm not sure that there is really a great option for you other than using Embedded Data. You can't really modify the name of a choice dynamically, but Embedded Data is difficult to report on. If you want it in a question for reporting purposes, your best bet is probably to have a hidden question on the final page that contains all possible contenders, and then to select that with JavaScript based on the selection made by the participant.

You can do that by using this JavaScript instead: https://gist.github.com/mattbloomfield/9bb4ea7c0ada5556db22bdba7138eda1

Additionally, you'll want to hide the question by adding this to the hidden question's javascript editor: https://gist.github.com/mattbloomfield/10fcee3ae8d8319fdf6f6ce7021024d4

If you get lost, I've attached the .qsf of this working example that you can import and take a look at. https://qualtricssfi.az1.qualtrics.com/jfe/preview/SV_dmaQ9qRlmBhZq3b?Q_SurveyVersionID=current&Q_CHL=preview

Leave a Reply