Results 1 to 3 of 3

Thread: Image CLICK counter

Hybrid View

  1. #1
    Join Date
    Dec 2011

    Question Image CLICK counter

    hello guys
    I have an Image on my page and I want to count how many times the image has been clicked on and show the number beside the image. Also I dont want the number to reset everytime the page is reloded.

    How can I do that
    Thank you for help

  2. #2
    Join Date
    Jul 2011
    You have to use AJAX for that purpose. And you also need to save your current counter somewhere on the server, for example in the database.
    Just send AJAX request only after clicking on the image and update the number of clicking.

  3. #3
    Join Date
    Oct 2010
    Versailles, France
    A simple image counter can be made without Ajax like on this page (see the source). The imagecounter.php file remove, on each call, the javascript file imagecounter.js with the new value and reload it to display this one...

    // imagecounter.php file
    	header("Cache-Control: no-cache, must-revalidate");
    	header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
    	$ncn='var count='.$nmb.';'.chr(13).chr(10);
    	// remove the js file   
    	// return the new script
    	echo $ncn;
    A single difficulty, it would be advisable to preload the sound !

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center