Help with money counter

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bboyson
    New Member
    • Jan 2010
    • 6

    Help with money counter

    Hello,
    I'm new to the programing world and i am trying to make a money counter for a charity group that will count how much money people donate and will update automatically when someone donates via pay pal or credit card. Can someone please walk me through this or post a link to a tutorial.
  • larztheloser
    New Member
    • Jan 2010
    • 86

    #2
    Can't do this in Javascript. Basically you'd get a server side script which stores the amount of people's payments on the server somewhere. PHP would be ideal.

    Comment

    • bboyson
      New Member
      • Jan 2010
      • 6

      #3
      Thank you, do you happen to no a good site with a tutorial on how to do this.

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Which language are you using on the server?

        There is one part where you can use JavaScript if you want: if you want to keep a counter on the page that does not require a reload. However, this would still require the server-side script for the actual count.

        Comment

        • bboyson
          New Member
          • Jan 2010
          • 6

          #5
          i use godaddys windows server to host my websites so i dont really use server lanugage but i would probably use php to make this counter instead of asp

          Comment

          • larztheloser
            New Member
            • Jan 2010
            • 86

            #6
            Well, there is a PHP forum for just this kind of thing!

            As for the javascript, it is as simple as this AJAX script:

            Code:
            function getMoneyCount(url)
            {
            if (window.XMLHttpRequest)
              {
              xmlhttp=new XMLHttpRequest();
              }
            else
              {
              xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
              }
            xmlhttp.open("GET",url,false);
            xmlhttp.send(null);
            //put your layer on the line below
            document.getElementById('moneyCounter').innerHTML=xmlhttp.responseText;
            }
            getMoneyCount("mc.txt"); //put your PHP output file here
            My script assumes the file has only one number in it - which it might not depending on which PHP script you use. Let us know if you need any more help!

            Comment

            • bboyson
              New Member
              • Jan 2010
              • 6

              #7
              Thanks that really helped

              Comment

              • acoder
                Recognized Expert MVP
                • Nov 2006
                • 16032

                #8
                Just two quick points:
                1. Line 10 can have true as the last parameter:
                Code:
                xmlhttp.open("GET",url,true);
                to avoid freezing the browser while waiting for a response, i.e. an asynchronous request rather than a synchronous one.
                2. Sometimes GET requests are cached. To avoid caching, set the appropriate headers or make sure it's a unique URL by appending the date string.

                Comment

                Working...