Auto-fill/Auto-select option, when just one option is shown and move ahead in the survey | XM Community
Skip to main content
How to auto select an option when the respondent is only shown one option and have him move ahead in the survey, without showing that particular question.
Instead of custom code,



Add display logic to that question such that - show if two or more option visible.

Now in survey flow add an embedded data that will store the response of this question if that was displayed else store the one option that was displayed
@Shruti,



If it is a multiple choice question, you can use the following. It has the advantage of the question being answered in the response data.

https://gist.github.com/marketinview/8310ba82acde38be62f007095bbe0278

The code TomG shared worked perfectly for me!
Some advice for those who don't know javascript, like myself:
Change the 'true' in this line to match whatever saved answer you're looking for.
qobj.setChoiceValue(displayedChoices[0], true)
I had a constant sum question for my follow-up question, so I changed it to this:
qobj.setChoiceValue(displayedChoices[0], 100)


https://community.qualtrics.com/XMcommunity/discussion/comment/23423#Comment_23423Thanks TomG - Solved it for me as well. Almost two years later! :)


If anyone is interested I have a more advanced function called skipFollowUp that serves the same purpose, but it works with multiple question types (MC, constant sum, constant sum slider, rank order, and PGR with one group), handles hiding the question so it doesn't flash on the screen, and addresses hiding the previous button on the next page.


Leave a Reply