Perform calculation on user entered number

We use hype for lots of presentations and animations. Where would I start to perform a calculation on a user-entered number (say, their income) and present them with a calculation (say, how much tax they would pay).

Is this possible?

You could use a input form on the innerHTML of a box (check the innerHTML of the top box in the sample), then use javascript to do the calculation from a button. Here’s a basic sample… (11.4 KB)


Thanks gasspence, your posts helps me on learning Javascript!

Will it be possible to make shapes like ellipses or rectangles to change dimension based on the calculation? I’ve seen some jQuery effect that does, but Hype may be able to make a bouncing growing shape stops on time line based on the calculation. That will be more interesting than an animation chart.

Something like this… (12.7 KB)

1 Like

Thanks very much for this. Will have a play around.

Has anyone else captured user variables for later use?

Hay gasspence,

Wanna say thank you for your knowledge sharing, I just make another version based on symbol. maybe you know a better way to do it. (maybe use javascript to control start or end keyframe? )

chart (17.8 KB)

1 Like

I really like what you have for this chart – good job Shong.

that’s really nice! thanks.

Hello gasspence. Thanks for helping us non programmers to go farther with hype. I have this calculation to perform with two inputed numbers:

(variable x - variable y / 60) * 600)

I tried to do it this way but it didn’t work

var UserAmount = document.getElementById('textbox_id').value; // from the innerHTML
var UserAmount2 = document.getElementById('textbox_id').value; // from the innerHTML

var y = ((UserAmount - UserAmount2 / 60) * 600); // calcul de la valeur chaulante

hypeDocument.getElementById('taxed').innerHTML = (y).toFixed(2); // two decial places

try something like this…

var UserAmount = document.getElementById('textbox_id').value; // from the innerHTML

var UserAmount2 = document.getElementById('textbox_id2').value; // from the innerHTML "note the 2"

var x = (+UserAmount) - (+UserAmount2); 

var z = (x /60) * 600

var y = (x * 1.0725); // 7.25% tax amount on user entry

hypeDocument.getElementById('taxed').innerHTML = (y).toFixed(2); // two decial places