Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jul 2010
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Javascript Counter

    Hey Everyone,

    I'm working on a counter. I have two images - each with their own click count. Right now each time the page loads the counter goes back to zero. I would assume I need some kind of server side coding.

    Any recommendations?

    Here's what I have so far.

    <html>
    <head>
    <script type="text/javascript">
    var counter = 0;
    function increaseloveit() {
    counter += 1;
    document.getElementById('loveit').value = counter;
    }
    var counter = 0;
    function increasehateit() {
    counter += 1;
    document.getElementById('hateit').value = counter;
    }
    </script>
    </head>
    <body>

    <form>
    <a href="#" onclick="javascript:increaseloveit();"><input type="button" value="Love It!" name="loveit" onclick="" /></a><input id="loveit" value="0" size="2" /></form>
    <form>
    <a href="#" onclick="javascript:increasehateit();"><input type="button" value="Hate It!" name="hateit" onclick="" /></a><input id="hateit" value="0" size="2" /></form>

    </body>
    </html>

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,918
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    http://www.codingforums.com/showthre...677#post976677


    What part of that did you not understand? One more time, you will need server-side scripting and a database.

    "It is better to keep your mouth closed and let people think you are a fool than to open it and remove all doubt." - Mark Twain, US humorist, novelist, short story author, & wit (1835 - 1910)

  • #3
    New to the CF scene
    Join Date
    Jul 2010
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I think you misunderstood my post. Thank you for the recommendation and help on my previous post. I am now looking into server side hosting like you recommended.

    I am asking for recommendations as to where I can get started with server side scripting...

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,918
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    Quote Originally Posted by reynoldscorb View Post
    I think you misunderstood my post. Thank you for the recommendation and help on my previous post. I am now looking into server side hosting like you recommended.

    I am asking for recommendations as to where I can get started with server side scripting...
    Well, in that case post your question in one of the server-side forums, e.g. PHP. This is the JavaScript forum. And your thread title is "Javascript Counter".


  •  

    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
    •