Maths operation using constant sum responses on the same page | XM Community
Skip to main content
I have a constant sum question where participants allocate tokens between categories. Depending on how they allocate tokens to each category they gain a payoff. I have created the payoff using a maths operation with piped text, this currently has to have a page break otherwise it does not calculate, so is displayed on the next page. The images show the current set up.



I would like to have the payoffs on the same page as the constant sum question, Qualtrics Support suggested Qualtrics Community for recommendations. I have seen a similar question and the answer suggests using JavaScript to dynamically update the page. Any help in how to achieve this will be greatly appreciated.





!





!



Thank you!
Use mouseup event handlers on the bars or an interval to trigger recalculation and update of the payoffs based on the current constant sum allocations.
Hi TomG,



I have no experience with code, would you be able to explain this a bit further please? Or recommend where to learn more, I would really appreciate it.



Thanks
ChloeM,



These are two different approaches:

1. Event handlers like mouseup (when the user releases the mouse button) execute a function when the event happens. So this allows you to take specific actions when a user interacts with an html element on the page. Actually, in this case, I think you need to detect a mousedown on any element with a class of track followed by a mouseup on the window (i.e., the user has moved a slider which means values have changed which means you need to recalculate the payoffs and update your table)

2. An interval set using setInterval executes a function every x milliseconds. If you set the interval to 500 milliseconds your function would recalculate the totals and update the table every 1/2 second.



I would classify these types of scripts as intermediate level JS.



w3schools has tutorials on JavaScript and jQuery (jQuery is included in Qualtrics and makes JS programming easier, but you should really understand JS first). They also have tutorials on html and CSS, which are prerequisites for learning JS since JS interacts with html elements.

Leave a Reply