Echo calculated values retrieved by the ajax function.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
drors30
Forum Newbie
Posts: 10
Joined: Sat Jan 12, 2008 1:59 pm

Echo calculated values retrieved by the ajax function.

Post by drors30 »

I have a a select box on my PHP file. Each time I select a value , several values are being retrieved
from MySQL.
I'm interested in calculating the value of one field called amount .
Namely, I want to have on the same page a variable that will add the new retrieved amount to the current SUM , calculate and present the total amount.
Each time I select a different value , current amount is being presented and the variable holds the total amount is being updated as well.
As I mentioned in the title, records are being retrieved using Ajax.
How can I achieve this ?
User avatar
jimthunderbird
Forum Contributor
Posts: 147
Joined: Tue Jul 04, 2006 3:59 am
Location: San Francisco, CA

Re: Echo calculated values retrieved by the ajax function.

Post by jimthunderbird »

This should be relatively easy even without using AJAX. Just work on the onChange event handling in the selection box, use one global variable in javascript to hold the sum.
drors30
Forum Newbie
Posts: 10
Joined: Sat Jan 12, 2008 1:59 pm

Re: Echo calculated values retrieved by the ajax function.

Post by drors30 »

Hi jimthunderbird,
Since i'm newbie can you refer me to a simple example ?

Thanks
Post Reply