recode value in Matrix question | XM Community
Solved

recode value in Matrix question

  • 18 September 2020
  • 2 replies
  • 182 views

Userlevel 2
Badge +6
  • Level 2 ●●
  • 11 replies

Hi!
I want to a create a variable based on responses to a set of statements in a matrix table. I am trying to do this by using the following. But this does not work. Anyone know of a different way? For example, using this.getChoiceRecodeValue(this.getSelectedChoices()); syntax? I don't know how to modify this for the matrix table.. thanks for any help!
Qualtrics.SurveyEngine.addOnPageSubmit(function() {
var paydec = "${q://QID94/SelectedAnswerRecode/3}";
if (paydec==="1"){
part2pay = 1.00;
}
else {
part2pay=0.40;
}

Qualtrics.SurveyEngine.setEmbeddedData("part2pay", part2pay);

icon

Best answer by rondev 18 September 2020, 23:42

View original

2 replies

Userlevel 7
Badge +22

Use the below code:
This code checks if row choice 3 and answer col 2 is selected then if condition is true. Similarly you can change the row and column number and add logic accordingly.
Qualtrics.SurveyEngine.addOnPageSubmit(function(type)
{
if(type == "next")
{
var part2pay;
if(this.getChoiceValue(3,2)){


part2pay = 1.00;
}
else {
part2pay=0.40;
}
Qualtrics.SurveyEngine.setEmbeddedData("part2pay", part2pay);


}
});

Userlevel 2
Badge +6

Thanks so much! This works perfectly!

Leave a Reply