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
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();
```
var choiceInputs = this.getChoices();
if(choiceInputs.length == 1) {
this.setChoiceValue(choiceInput[0], true);
this.clickNextButton();
}
```
> 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:
Let 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!!
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.