Question
Set answers for hidden question based on previous question's answer
A newbie to Qualtrics custom code with a request for advice ... even better if someone has a code snippet that is close to what I want ...
I have a survey with several matrix single answer likert questions. Depending on a response to a question prior to the matrix question I would like to set the selected answers to the matrix question, ideally without having the survey participant see this being done or need to press the next button. The previous question is a "yes / no" question, so it's recode value for the answer isn't what I'm trying to use to set the matrix question answers.
As far as I can tell the only way to do this in Qualtrics is to use JavaScript in the matrix questions. Question #1: Am I correct, or is there another way to get responses recorded for a question the survey participant does not see?
I'd like to re-use the JavaScript code code for multiple matrix questions, so hard coding the choiceID, recodeValue, subid, etc. of the matrix questions isn't a good idea.
Studying the Qualtrics documentation and posts I think this is the way to go:
Use Qualtrics.SurveyEngine.QuestionInfo to iterate through the matrix question. This will give me the IDs and subids I need to set.
Use piping syntax to get the previous questions answer, set it to a JS variable, used in conditional coding.
Use the previous answer to decide how to answer each row of the matrix question. Use setChoiceValue to set the choice. I have experimented with setChoiceValueByRecodeValue. Question #2: I couldn't find too many examples that illustrate the use cases for the Qualtrics JavaScript APIs. I assume setChoiceValue uses a string that matches the value I want to set, versus using the recode value. Is that right?
Use clickNextButton to cleck the next button.
Question #3: Any comments on teh above approach?
Question #4: How do I make this "invisible" to the survey participant? I saw a post onn the forum where someone mentioned they "hide the skin" in the JavaScript code, but I couldn't find anything that helped me understand what that means.
If you've read this far many, many, many thanks!
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
