Getting the column choice values from a matrix table | XM Community
Skip to main content

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);
});

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.


Yes to transposed, also single select.
image.png



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);
});


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?


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