David Lim
Posts: 0
Joined: Wed Mar 12, 2014 3:58 am

Appery Click Coding for Javascript

I want to ask is there a Click function for Javascript,
Where user Click a Image Component , Another Image appear for multiply times as the user click.

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Appery Click Coding for Javascript

Hello David,

You can add click event handler for any component. http://docs.appery.io/documentation/w...

David Lim
Posts: 0
Joined: Wed Mar 12, 2014 3:58 am

Appery Click Coding for Javascript

Can it be done in Javascript?
Since i may be using "if" "else" when is the user click repeatly and different image appear on a same image component

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Appery Click Coding for Javascript

Sure, you can do it. Just save count of clicks in localStorage.
For example:
var clicks = parseInt(localStorage.getItem("clicks"));
if (clicks ) == 0){
Apperyio("imageName").attr("src","http://example.com/image1.png");
} else {
Apperyio("imageName").attr("src","http://example.com/image2.png");
}
localStorage.setItem("clicks", clicks + 1);

Note: imageName - name of image component

Return to “Issues”