Getting the column choice values from a matrix table | XM Community
Solved

Getting the column choice values from a matrix table

  • 24 April 2021
  • 5 replies
  • 199 views

Userlevel 2
Badge

I have a matrix with two columns. I want to get the inputs of both columns on page submit. I have been using

getChoiceValues
, and I have no problem getting the value of the right column. How can I get the value of the left column?
Qualtrics.SurveyEngine.addOnPageSubmit(function()
{
// this does not work
let left_column_choice = this.getChoiceValue(0);
// this works for sure
  let right_column_choice = this.getChoiceValue(1);
});

icon

Best answer by whitesoxs141 27 April 2021, 19:45

View original

5 replies

Userlevel 2
Badge +3

whitesoxs141
Is your matrix transposed? Is it single or multi select?
If you could share a screenshot of your Question (from inside the survey editor), or share a Preview Survey link, I could probably get you an answer.

Userlevel 2
Badge

Yes to transposed, also single select.
image.png


Userlevel 2
Badge +3

whitesoxs141 oh ok, I think your mistake is minor.
Instead of using 0 and 1, you should be using the ChoiceID which are likely 1 and 2.
So:
Qualtrics.SurveyEngine.addOnPageSubmit(function()
{
// this does not work
let left_column_choice = this.getChoiceValue(1);
// this works for sure
  let right_column_choice = this.getChoiceValue(2);
});

Userlevel 2
Badge

Hmm not quite, I added this to my JS
image.pngand randomly selected options in both columns. Here what I get in the console.
image.pngDo you have more advice on getting the correct choice ID's?

Userlevel 2
Badge

I found the question ID using this in my console Qualtrics.SurveyEngine.QuestionInfo.QID887

image.png
Miraculously, the left column has ID 16? Anyway this works! Thank you so much!

Leave a Reply