Javascript to auto-populate next question based on the answer in a previous | XM Community
Skip to main content
Hi everyone,

We have a survey where we have three questions:

-Did we solve your issue? (Y/N)

-If prior question was answered N, why wasn't it solved (multiple select)?

-Overall, what was your satisfaction with this inquiry? (1-10 value)



If the user selects the 1st question as No, and says their issue is not resolved in the 2nd question, I don't even want to ask the 3rd overall question. However, I'd like to populate the value of that question answer as 1, as anyone with an issue not resolved I want to log as dissatisfied. I don't want that value to be null.



Is there some Javascript that I could write in the survey that would be able to do this?
Instead of JS, you can add display logic to Q3 as - show only if Yes is selected in Q1. And in the survey flow create an embedded data as "rating". Assign this embedded data based on the branch logic - if Q1 No is selected rating = 1 else rating = Selection choice of Q3

Leave a Reply