Auto-Code Response for a Carry Forward Question from a Multiple Answer Multiple Choice Question | XM Community
Skip to main content
Hi All,



A little new here to the platform. I contacted Qualtrics support to see if I can apply some custom code for a Carry Forward question, but they mentioned this might require some javascript to show correctly.



So the initial question is a Multiple Answer Multiple Choice question. I used the Carry Forward Choices to populate the next question (so if the survey taker selects 5 out of the 10 responses in Q1, they then see those 5 responses in the Carry Forward question, which is a Single Answer Multiple Choice question, and they select one answer from those 5 responses). 2 of those responses are exclusive and if selected, I have Display logic to not show the Carry Forward question. I also have Display logic to only show the Carry Forward question IF more than one response is selected from the Multiple Answer Multiple Choice question.



What I want to do is if only one response is selected in the Multiple Answer Multiple Choice question, I basically want to auto-populate the Carry Forward question with that one response, and NOT show the Carry Forward question. Is there a possible solution here using javascript? I believe I have already solved for skipping the question if they selected one of the exclusive options (e.g., Don't know) and displaying it if there is more than one response selected from the original question, but trying to solve for this auto-population if one response is selected.



Thanks!

Karlo
I am new to qualtrics so the answer that I'm providing must be taken with a pinch of salt. So, I am assuming that you have your logic right and are already able to differentiate when your question fetches only one choice in your single choice(carry forward) question that follows the multiple choice multiple answer question.

Thereafter, you need to add this line of code in javascript of your carry forward question:



document.getElementById(document.getElementsByClassName('q-radio').item(0).htmlFor).checked = true;



You can use an embedded data which can be set to 1 if there is only one choice that is carried forward, 0 otherwise.



If you don't want to display this carry forward question to the user if it has only one choice, you can check if the embedded data is set to 1 and can skip to the next page directly by using:



$('NextButton').click();
Show the follow-up question if at least 1 choice is selected in the first question, then try adding this to your addOnReady function on the second question:

```

var choiceInputs = this.getChoices();

if(choiceInputs.length == 1) {

this.setChoiceValue(choiceInput[0], true);

this.clickNextButton();

}

```
How about multiple autocoding?
> @Kennedy_Isip_Kantar said:

> How about multiple autocoding?



Can you be more specific and start a new thread?

Tom - I know this post is a couple of years old but I've inserted this as shown above but for some reason it is not auto populating in the data. Can you help?
var choiceInputs = this.getChoices();
if(choiceInputs.length == 1) {
this.setChoiceValue(choiceInput[0], true);
this.clickNextButton();
}



Please ignore the above question...I've figured it out!!


Melissa_Kaiser_psu89 How did you get it working? I've just added it and can't get it to auto populate


Here's the JavaScript code I used on the question that has the carry forward choices:
image.pngLet me know if you have any other questions!


Hi Melissa_Kaiser_psu89 . You posted this a long time ago. I'm new to Qualtrics and have no Java script knowledge.
I hope you can help me. I have a similar need with a Carry Forward question.
Q15 = Multiple option
Q16 Carries forward selected options from Q15. But, as many of us, how can I do to skip Q16 (but record the answer in the database) if Q15 has only one answer.
I hope you can help me.
Raúl


RVargas72 ,
Use the code at the link below. Add the JS to Q16.
https://gist.github.com/marketinview/8310ba82acde38be62f007095bbe0278


Thank you so much!!


https://community.qualtrics.com/XMcommunity/discussion/comment/47118#Comment_47118Thank you!😀


Leave a Reply