Re: show number of clicks?

Giganews Newsgroups
Subject: Re: show number of clicks?
Posted by:  Evertjan (exjxw.hannivoo…@interxnl.net)
Date: 01 Mar 2008

Geoff Cox wrote on 02 mrt 2008 in comp.lang.javascript:

> Hello
>
> The code below counts the number of times that the image is clicked.
>
> I would like to be able to dispay the number of clicks when the user
> decides that he/she wishes to know the total at that point.
>
> 'would appreciate some ideas on how to do this.
>
> Cheers
>
> Geoff
>
> <script type="text/javascript">
>
> function countClicks(thecount){
> document.getElementById(thecount).innerHTML =
> parseFloat(document.getElementById(thecount).innerHTML)+1;
>}
> </script>
>
> <img src="images/count.gif" onclick="countClicks('number');">
>
> <span id="number" style="visibility:hidden">0</span>

<script type="text/javascript">

var counter = 0;

function countClicks(){
  counter++;
};

function showClicks(thecount){
  document.getElementById(thecount).innerHTML = counter;
};

</script>

<img src="images/count.gif" onclick = "countClicks();">
<br><br><span id="number"></span>
<button onclick = "showClicks('number');">Show</button>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Replies

In response to

show number of clicks? posted by Geoff Cox on Sat, 01 Mar 2008