KarenW
Posts: 0
Joined: Sun May 11, 2014 7:17 am

display counter on screen and store count

Hi I'm new to appery .
I want a user to be able to have a user press a button and have it count the number of times it has been pressed. I want this displayed on the screen next to the button - like a counter. I also want to store the total count. What is the easiest way to achieve this please
cheers
Karen

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

display counter on screen and store count

Hi Karen,

You can achieve this using JavaScript with jQuery, this is one of the ways:
Let's assume you have the Label component and the Button on your page - on button click event add this JS:
precode
Apperyio('your_label').text( function(i, val) { return +val+1; });
// this will return value iteration inside the label each time you click the button
/code/pre
On another button you can store the final cont value inside the local storage variable, on button click event add this JS:
precode
var counts = Apperyio('your_label').text();
// here we put the current value inside the label component in variable 'counts'
// and store this value inside the local storage variable for later usage in your app
localStorage.setItem('total_counter', counts);
/code/pre

KarenW
Posts: 0
Joined: Sun May 11, 2014 7:17 am

display counter on screen and store count

hi thanks
I have no idea about jquery but ill give it a go
thanks

Return to “Issues”