Web based Mouse Click Counter Application

Discussion in 'Programming' started by MelogKnaj, Aug 26, 2008.

  1. #1
    I am trying to make a simple application that counts and displays the number of times a user clicks within a box on a webpage. What language should I be using to do this? Any suggestions on just how to do it? +reps for useful responses.
     
    If someone posts a solution, use the "Best Answer" link in their post to pick it as the best answer.
    MelogKnaj, Aug 26, 2008 IP
    Barti1987 likes this.
  2. jack_ss

    jack_ss Guest

    Messages:
    94
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Use Javascript.
    <head>
    	<script>
    	<!--
    	var count = 0;
    	-->
    	</script>
    </head>
    <body onclick="alert(count++);">
    </body>
    PHP:
    You can put the onclick on a <div> to control the size and you can output the count++ to an <input> or you can use simple AJAX like Javascript/PHP to save it to a database or text file.
     
    jack_ss, Aug 26, 2008 Set Best Answer IP
    1 person likes this.
  3. Barti1987

    Barti1987 Well-Known Member

    Messages:
    2,703
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    185
    #3
    Use Javascript to activate onclick. Use Ajax to call a PHP page in the onclick function.

    The PHP page will increment +1 to the user clicks.

    Peace,
     
    Barti1987, Aug 26, 2008 Set Best Answer IP
    1 person likes this.
  4. eponus

    eponus Peon

    Messages:
    34
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    AJAX / PHP is probably overkill, stick with the Javascript if it's just a fun game.
    If there's actually something of value involved that needs to be tracked, then use a server side language like PHP.
     
    eponus, Aug 27, 2008 Set Best Answer IP
  5. MelogKnaj

    MelogKnaj Guest

    Best Answers:
    0
    #5
    Thanks for the help so far. I am trying to make an application that counts the number of times you click within a box in a given time frame. I am having trouble figuring out how to make the timing part work though, the only things I can find is a function that has a time delay until the code executes. Help?
     
    MelogKnaj, Aug 30, 2008 Set Best Answer IP