Page 1 of 1

click counter

Posted: Thu Jun 06, 2013 4:02 pm
by habib

hello,
i want to make a click counter, so it should be like 2 buttons , one for addition & the other subtraction, and a placeholder to see the results of the clicks.
so how it could be made, & plx if u can be specific because I'm new to development
thank you


click counter

Posted: Thu Jun 06, 2013 4:16 pm
by Kapow36

well, drag a label, and your two buttons onto your page with the drag and drop ui

name the label: placeholderLabel, set the default value to a zero or whatever you want

name the plus button: plusButton

name the subtract button: subtractButton

on each button, add an event (on a click) and then select the run javascript action

javascript code for both buttons:

code
var label = Appery('placeholderLabel');//label object

var newValue = Number(label.val());//gets what is currently in the label and converts it to a number

// put newValue++; or newValue--; here depending on which button you put this code in for

label.val(newValue);//sets the label text
/code

that should do it, hope this helps!


click counter

Posted: Thu Jun 06, 2013 4:17 pm
by Kapow36

Just a note, there are many ways to do this, this is just one way. You could also use local variables etc.


click counter

Posted: Thu Jun 06, 2013 4:20 pm
by Kateryna Grynko

Hi,

This seems to be a good solution.