Constant Sum question Total Show the Sum of Items selected | XM Community
Solved

Constant Sum question Total Show the Sum of Items selected

  • 15 November 2018
  • 1 reply
  • 4 views

Badge +1
Need some help trying to create a question that works this way...

Users sees a list of items with associated prices. E.G. A $10 B $100, C $150
User can choose any combination of items they like and when they do so, the Constant Sum Total cell shows the $Total for those selected.
E.G. A and B shows $110, B and C shows $260.

The only way I can figure out how to do this currently, is to use the standard constant sum question w/Total and have the user type in the $ figure
for each item they choose. Not horrible UX but I would prefer they just select the items using the check boxes.

Any ideas or help would be most appreciated.
icon

Best answer by TomG 15 November 2018, 02:43

View original

1 reply

Userlevel 7
Badge +27
You'll have to write some JavaScript...

Put each price in a span with a specific class, something like:
```
A $<span class="price">10</span>
B $<span class="price">100</span>
etc...
```
Then any time a choice is clicked, find the selected items then within those find all the prices and add them up. Then update a total field (e.g. `<span id="total">0</span>` ) you place in the QuestionText or append to the bottom of the QuestionBody.

Leave a Reply