Data Punching in Hidden Variable (Multi response) using "setChoiceValue" function | XM Community
Question

Data Punching in Hidden Variable (Multi response) using "setChoiceValue" function

  • 21 August 2019
  • 3 replies
  • 101 views

Q1- I am new to this tool. i am trying to set the data on the dummy variable. I've used carry forward functionality. So the total no of categories displayed should be set in hidden variable. We've used the below code for the same. But the problem is when we test it using back and forwarding the survey it does not work for few cases. We are not sure why this is happening. Please suggest.

code is below -

if (this.getChoiceDisplayed("x1")) { this.setChoiceValue("x1",true) ;}
if (this.getChoiceDisplayed("x2")) { this.setChoiceValue("x2",true) ;}
if (this.getChoiceDisplayed("x3")) { this.setChoiceValue("x3",true) ;}

Q2- Also, is there any way to show the question in read Only mode, so that we can show our hidden question in the survey for testing purpose?

3 replies

Q1 - I tried the below code and worked perfect.

Qualtrics.SurveyEngine.addOnload(function()
{
/*Place your JavaScript here to run when the page loads*/

var choiceInputs = this.getChoices();
var i=0;

for (i = 0; i < choiceInputs.length; i++) {
this.setChoiceValue(choiceInputs[i], true);
}

});

Q2- i am not sure how to do it. Still learning..
Arvind, thanks for the response! that helps.
Userlevel 4
Badge +18
For second point you can use css\\js to make question readonly. Relevant discussion was done on:-

https://www.qualtrics.com/community/discussion/comment/17117#Comment_17117

Leave a Reply