Easy A
Would you like to react to this message? Create an account in a few clicks or log in to continue.


 
HomeHome  Latest imagesLatest images  SearchSearch  RegisterRegister  Log inLog in  

Share
 

 Help with a button click counter

View previous topic View next topic Go down 
AuthorMessage
Escape
Member
Member
Escape

Posts : 16
Join date : 2011-03-09

Help with a button click counter  Empty
PostSubject: Help with a button click counter    Help with a button click counter  EmptyThu Mar 10, 2011 12:27 am

Ok so I am trying to make a green button that says "Count Your Hit" and everytime someone presses the button it keeps count. And above the button it says " (the number) Hits" Can anyone help me? Because I cant get it.

Thanks.
Back to top Go down
Tetris
Admin
Admin
Tetris

Posts : 109
Join date : 2011-03-08

Help with a button click counter  Empty
PostSubject: Re: Help with a button click counter    Help with a button click counter  EmptyThu Mar 10, 2011 12:27 am

Code:

<html>
<head>
<script><!--
var Clicks = 0 ;
function AddClick(){
Clicks = Clicks + 1;
document.getElementById('CountedClicks').innerHTML = Clicks + ' Hits';
}
// --></script>
</head>

<body>
<span id="CountedClicks">0 Hits</span><br>
<button style="background-color:green" onclick="AddClick()">Count Your Hit</button>
</body>

</html>
Back to top Go down
https://easya.forumotion.com
Escape
Member
Member
Escape

Posts : 16
Join date : 2011-03-09

Help with a button click counter  Empty
PostSubject: Re: Help with a button click counter    Help with a button click counter  EmptyThu Mar 10, 2011 12:28 am

Admin wrote:
Code:

<html>
<head>
<script><!--
var Clicks = 0 ;
function AddClick(){
Clicks = Clicks + 1;
document.getElementById('CountedClicks').innerHTML = Clicks + ' Hits';
}
// --></script>
</head>

<body>
<span id="CountedClicks">0 Hits</span><br>
<button style="background-color:green" onclick="AddClick()">Count Your Hit</button>
</body>

</html>


Thanks So much! but everytime I load the website page again the count goes back to zero. What do I have to do to make it keep the count?
Back to top Go down
Knowledge
Member
Member
Knowledge

Posts : 21
Join date : 2011-03-09

Help with a button click counter  Empty
PostSubject: Re: Help with a button click counter    Help with a button click counter  EmptyThu Mar 10, 2011 12:29 am

you need to save the value somewhere. either in a cookie, the storage objects (new in HTML5 and not supported by every browser) or on the server.
Back to top Go down
Sponsored content




Help with a button click counter  Empty
PostSubject: Re: Help with a button click counter    Help with a button click counter  Empty

Back to top Go down
 

Help with a button click counter

View previous topic View next topic Back to top 
Page 1 of 1

 Similar topics

-
» Data grid binding a balnk after "add new row" button click
» Disable right click on websites
» www.visualock.webs.com right click disabling
» Edit Windows Right Click menu
» how to create a pop out button

Permissions in this forum:You cannot reply to topics in this forum
Easy A :: Help with a button click counter  Edit-trash Useless :: Trash-