Side by side question with one selection per column | XM Community
Question

Side by side question with one selection per column

  • 29 September 2020
  • 3 replies
  • 198 views

Hello everyone,
I'm creating a survey and would love to get some help with custom code for a side by side question. The survey is set up so that a respondent can give feedback on at least 1 product and up to 3 products, and I use a side by side question to determine what product 1, product 2, and product 3 will be. (I'm using a side by side question because it helps with piping certain information throughout the survey so I don't want to change the question type to a matrix or something else.) I've done some research but can't find a way to make answer choices exclusive for each column. I'm attaching example pictures below to help me talk through the situation. I want respondents to select only one product in column 1 (choice 1) and only one product in column 2 (choice 2) and only one product in column 3 (choice 3). When testers select multiple products in a column, it creates errors and prevents our survey flow from working correctly. It would be great if we could also force a respondent to select at least one product. I would appreciate any help with writing some custom code to create single answer options for each column.

Example question:
SidebySideExample.PNGMultiple answers selected in the same column (what we don't want to happen):
WrongSidebySide.PNG
Thank you for your help!


3 replies

Userlevel 7
Badge +27

In hindsight, the correct question type would have been a transposed matrix.
If you stick with a SBS, you can do this with JavaScript. The first step is to make all the SBS columns multi-select (checkboxes) so you'll be able to easily unselect them. Then add event listeners to all the checkboxes so when one is selected all the others in the same column are unselected.

Thank you for that suggestion! Could you provide an example of/link to the JavaScript needed to add event listeners to the checkboxes? Also, would the checkboxes change how I pipe the answers through the survey? I'm currently using ${q://QID3%231/ChoiceGroup/SelectedChoicesForAnswer/1} for the single answer option.

Userlevel 7
Badge +27

Example event handler JS:
jQuery("#"+this.questionId+" .SBS1 input[type=checkbox]").click(function() {
// do something here
});
I don't think the pipes will change when you switch from single answer to multi-answer.

Leave a Reply