Use JS to sum inputs of Matrix Table Dropdown List | XM Community
Skip to main content

Hi all,
I have a Matrix Table (Type: Profile, Answers: Dropdown List) with 2 Statements and 10 Scale Points. Participants need to allocate 10 points between two options. To ensure that they use exactly 10 points, i'd like to make a custom validation whereby both statements need to sum up to 10. To do that, I wanted to sum the answer for both statements in a hidden text question and use it for validation.
My questions:

  1. How do I use JS to sum the value of both statements in a questions?

  2. How do I use JS to hide that question?


Any help would be appreciated. Thanks!
Best

You can actually use a constant sum question to solve the validation problem for you. So you won't need any JS.
Hiding a question is easy : this

.getQuestionContainer().hide(); 

However, to ensure both choices are equal to 10 using JS will get a little complicated, as you'll have to set up and event listener, that triggers every time their choice changes, which will hide or show the next button.


Leave a Reply