Add number variables without a button

Aug 08, 2023

Hi!

I’m trying to create a slide where the learner types in multiple numbers, which all add up to a total displayed at the bottom of the same slide. I want to be able to display the total at the bottom and have that update as the learner enters each number (without needing to click a button to trigger adding the numbers). Using triggers to add the variables to a total variable (displayed at the bottom) works great unless the learner decides to change a number. When this happens, the total continues to add. Thoughts on how I can make this function without a button even if the learner decides to change a number? 

Thanks!!

7 Replies
Walt Hamilton

Ask yourself, "When do I want the total recalculated?", and there's your answer.

If I were doing what you describe, I think I would want to recalculate when one of the 7 variables changes. There is a trigger "when" for that. Like Michael says, every time any one of the 7 changes, set the total to 0, and add all 7 together.

For a way to create fewer triggers, see the attached sample.

Megan Gonzalez

Thanks all!  I appreciate the help!  I was able to get it to work. I ended up setting up triggers to reset and then calculate all 7 numbers.  Unless I'm missing a simpler way to do this, I put all of these triggers on each of the number variables.  Turns out part of my issue when working on this was coming up with a NaN error, which I had assumed was because I was doing something wrong. But I guess I needed a condition to only add the variables if the value is greater than or equal to zero to eliminate this error!