Using Carry-forward to auto-populate answers in a follow-up question | XM Community
Skip to main content
Hello all,

Is there a way for me to carry forward an answer from a question, into another question and have that answer be logged as the respondent's answer to the second question? My issue is that if the respondent answers X to question #1, then their answer must be X for question #2 but that answer choice is the only one in both questions that has this characteristic. Ideally, if they answer X in the first question then the survey would auto-record that as their answer to the second. Is it possible to do this?

Thanks
Yes, you need to use JavaScript on the 2nd question to do it. Assuming you are carrying over selected choices from the 1st question, the JavaScript needs to see if the X choice is present in the 2nd question, and if it is select it and click the Next button.
> @TomG said:

> Yes, you need to use JavaScript on the 2nd question to do it. Assuming you are carrying over selected choices from the 1st question, the JavaScript needs to see if the X choice is present in the 2nd question, and if it is select it and click the Next button.



Thanks for your response. I'm not really versed in JavaScript but I can learn. Is there any sort of script library in the community that I can use to help me hone in on the correct solution?
> @aSangasy said:

> Thanks for your response. I'm not really versed in JavaScript but I can learn. Is there any sort of script library in the community that I can use to help me hone in on the correct solution?

>

There isn't a library as part of the community. You can find various code snippets in Developer Corner - Custom Code threads.



Let's say X is choice id 2 in the 1st question, then the choice id in the 2nd question is x2, and the JS would be:

```

Qualtrics.SurveyEngine.addOnload(function() {

var autoChoice = jQuery("#"+this.questionId+" input[choiceid=x2]");

if(autoChoice.length == 1) {

autoChoice.prop("checked", true);

this.clickNextButton();

}

});

```
Thanks for the code. I'll drop that in and fiddle with it this morning.

@TomG  I hope you can help me.  I have a very similar need as the one exposed in this post.

 

P1 is a multiple response question accepting multiple answers, asking the interviewee to choose all the banks where he has an account.
P2 asks if he has an e wallet or another financial app. ( Options Yes / No)

P3 asks to choose the names (multiple choice) of the  e-wallets if they chose YES in P2

P4 ask for their main financial institution (only one answer) letting them choose from all the brands or options in P1 and  P3 (this is not a carry forward question since it has all the possible options of P1 and P3)

My client wants me to auto select and go to the next question automatically if in P4 the interviewee  ONLY chose Code 7  in P1 and said NO in P2.

Can you help me with the JS I need to put in P4?  I really appreciate your help.


Leave a Reply