Hiding choices by excluding specific recode values using Javascript | XM Community
Skip to main content

Hi,
I have a hidden question with 80+ choices. I only want to show 3 choices based on a combination of recode values from 2 previous questions. Here's an example to be clear:
region question has a code of 0 to 3
segment question has a code of 0 to 6
the hidden question has recode values like these where the segment question is the second digit and the region question is the third digit:
100, 101, 102, 103
110, 111, 112, 113 and so on until it gets to 160, 161, 162, 163
and then it moves to the 200 series and 300 series
200, 201, 202, 203....
300, 301, 302, 303....
So if region is 0 and segment is 1, I only want to see 110, 210 and 310

I was able to pre-select the 3 choices I want to see using Javascript but what I really want is to display only those 3 and hide everything else. The reason for this is because I need to use randomization that evenly displays choices. the first digit is a concept that I will display and the client wants to balance the exposure by region and segment.

rarcega - This can be setup by creating the following three variables in survey flow:
image.pngThe above variables will give us the recodes for the three choices to be displayed in the hidden question with 80+ choices. Now we need to add choice display logic on each choice to display if the corresponding embedded data is equal to its recode value.

The above setup for setting embedded data requires the question with 80+ choices to be in a separate block. However, that is not mandatory as you can achieve the same using JS.


Leave a Reply