I am a newbie to Java so - a. sorry b. help!


#1

Am I being dim - this works great with 2 sliders but doesnt work when you add a 3rd…?<

// gather amounts
var amount1 = hypeDocument.currentTimeInTimelineNamed('slider 1');
var amount2 = hypeDocument.currentTimeInTimelineNamed('slider 2');
var amount3 = hypeDocument.currentTimeInTimelineNamed('slider 3');

// calculate sum
var sum = (amount1 + amount2 + amount3);

// get elements
var amount1Element = hypeDocument.getElementById('amount1');
var amount2Element = hypeDocument.getElementById('amount2');
var amount3Element = hypeDocument.getElementById('amount3');

var sumElement = hypeDocument.getElementById('sum');

// set elements to new values
amount1Element.innerHTML = amount1.toFixed(0);
amount2Element.innerHTML = amount2.toFixed(0);
    amount3Element.innerHTML = amount3.toFixed(0);

sumElement.innerHTML = sum.toFixed(0);

(Jonathan Deutsch) #2

It looks fine to me - is your timeline named exactly “slider 3” and is your element named exactly “amount3” ? Might be easier to post a zip of your .hype document because one cannot test any theories without it.


#3

will do !

Thanks


#4

Fixed it !

I was missing the unique ID for the 3rd slider - now works great - see belowadding_sliders_sum-2.zip (104.3 KB)


#5

Just thought I’d share the work in progress for this project - this link is for the MOBILE only version - but it uses Java script ( newbie style ) and Hype.

http://www.brewerylondon.com/HCV2/HCV2.html


(Jonathan Deutsch) #6

Wow, that’s awesome - now I see why you wanted the sliders and sums to work!


(Mark Hunte) #7

Very nice.

I do notice the slide handles stick when you go all the way to 10. It then becomes difficult to slide it back. I found I would need to tap twice hold and then drag…


#8

Thanks for the spot - have fixed and will share later when more finished.


#9

99% done - thanks for comments

http://www.brewerylondon.com/BLHC2018/BLHC2018.html