473,378 Members | 1,354 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

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.
Jan 30 '10 #1

✓ answered by larztheloser

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

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

Expand|Select|Wrap|Line Numbers
  1. function getMoneyCount(url)
  2. {
  3. if (window.XMLHttpRequest)
  4.   {
  5.   xmlhttp=new XMLHttpRequest();
  6.   }
  7. else
  8.   {
  9.   xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  10.   }
  11. xmlhttp.open("GET",url,false);
  12. xmlhttp.send(null);
  13. //put your layer on the line below
  14. document.getElementById('moneyCounter').innerHTML=xmlhttp.responseText;
  15. }
  16. 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!

7 2212
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.
Jan 30 '10 #2
Thank you, do you happen to no a good site with a tutorial on how to do this.
Jan 30 '10 #3
acoder
16,027 Expert Mod 8TB
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.
Feb 1 '10 #4
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
Feb 1 '10 #5
Well, there is a PHP forum for just this kind of thing!

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

Expand|Select|Wrap|Line Numbers
  1. function getMoneyCount(url)
  2. {
  3. if (window.XMLHttpRequest)
  4.   {
  5.   xmlhttp=new XMLHttpRequest();
  6.   }
  7. else
  8.   {
  9.   xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  10.   }
  11. xmlhttp.open("GET",url,false);
  12. xmlhttp.send(null);
  13. //put your layer on the line below
  14. document.getElementById('moneyCounter').innerHTML=xmlhttp.responseText;
  15. }
  16. 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!
Feb 2 '10 #6
Thanks that really helped
Feb 7 '10 #7
acoder
16,027 Expert Mod 8TB
Just two quick points:
1. Line 10 can have true as the last parameter:
Expand|Select|Wrap|Line Numbers
  1. 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.
Feb 7 '10 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

15
by: chahnaz.ourzikene | last post by:
Hi all, This is the first i post in this newsgroup, i hope my english is not too bad... Let's get straight to the point ! I have a little probleme using threads in my little training example :...
7
by: brian.digipimp | last post by:
Write a program that prompts the user to input a positive integer. It should then output a message indicating whether the number is a prime number. (Note: An even number is prime if it is 2. An odd...
2
by: atreide_son | last post by:
hello all... yes i'm a newbie and i need help. i have an assignment due for class, but I don't know i'm stuck and can't get out from under myself. here's the focus of the program: Write...
2
by: cJ500 | last post by:
I can't figure out the problem with this code. I'm using a Borland compiler. The problem is with the / operation overload. When I call isNeg it doesn't output true or false. Now I know this code...
2
by: rookiejavadude | last post by:
I'm have most of my java script done but can not figure out how to add a few buttons. I need to add a delete and add buttong to my existing java program. Not sure were to add it on how. Can anyone...
2
by: Zerofury | last post by:
Okay this is what i'm attempting to do. I have to modify this program that i wrote so that it allows the user to list items by alpha as an option on the main menu. Here is my problem. If i sort the...
0
by: yjh0914 | last post by:
hi guys! so im basically editting my post i made earlier as it wznt as specific.. i have to make a program that basically ranks students by their cumulative gpa. the student's info is on a csv file...
2
by: ccarter45 | last post by:
Okay, so I need to write this program that first declares an array and inputs the number of each snake present on a plane (there are 5 diff. snakes). Next, it must print out the number of each snake:...
0
by: brossyg | last post by:
I have some VBA code that creates an email in Access and sends it from Outlook. It is based on a query with a list of email addresses. It sends the first email to Outlook and then I have to manually...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.