Page 1 of 1

Echo calculated values retrieved by the ajax function.

Posted: Mon Jan 14, 2008 5:07 am
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 ?

Re: Echo calculated values retrieved by the ajax function.

Posted: Mon Jan 14, 2008 5:33 am
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.

Re: Echo calculated values retrieved by the ajax function.

Posted: Mon Jan 14, 2008 5:48 am
by drors30
Hi jimthunderbird,
Since i'm newbie can you refer me to a simple example ?

Thanks