Checking if answers from drop down answers match | XM Community
Skip to main content

Hello! I’m creating a custom validation via the survey flow, where I will be asking the same question twice (in the beginning and in the middle of the survey). Basically, I’m trying to see whether the participant chooses the same answer when asked twice. 

 

One validation question I’m thinking is checking if the participants choose the same state from the dropdown menu. The following is how the question looks like and its respective JS script. Moreover, I’ve already set the embedded variables in the front of the survey flow: 

The following is an image of the survey flow

 

 

Basically, I’m trying to see whether the input answers from State1 and State2 match with each other. If they do not, the survey will end immediately.

 

However, even after I put in the same answer for State1 and State2, the survey ends immediately. I could use some guidance or help on how to fix this or implement a better efficient way to validate using two answers from two drop down questions.

 

Thank you!

 

Hi @JoshUR this can be done without Javascript using embedded data, pipe text and branch logics. Refer below images.

Block 1 will have 1st dropdown question and then create ‘State_1’ embedded data to store the selected choices.
Repeat the same step for block 2 having 2nd dropdown question and create ‘State_2’ embedded data.
Then create a branch logic which will check ‘State_2’ embedded data is not equal to selected choice of 1st question, if the condition meets, he/she will be redirected to end of survey.

 


Unfortunately, I’ve did that previously and again now and it doesn’t seem to be working.

 

For example, when I choose ‘Alabama’ for the first dropdown menu and ‘Alabama’ for the second dropdown menu, I’m directed to the end of the survey. 


@JoshUR,

Your branch condition should be:

If State_1 Is Not Equal to ${e://Field/State_2}


I’ve done as you suggested and it worked: 

Thanks for your help! Greatly appreciate it :) 


Leave a Reply