PDA

View Full Version : How to get values from different functions?


Stoffel
01-29-2003, 01:23 PM
Hiya,

For my website, I have 5 different functions
In each of those functions there is a price to calculate

But how do I make a total of those 5 prices?

Hope u understand what I mean and u can help me

mordred
01-29-2003, 01:31 PM
Let each function return a subtotal so you only have to sum up all subtotals. Example:


var sub1 = calculate1(var1);
var sub2 = calculate2(var2);
var sub3 = calculate3(var3);
var sub4 = calculate4(var4);
var sub5 = calculate5(var5);

var total = sub1 + sub2 + sub3 + sub4 + sub5;


according to your specific situation, there may of course be more elegant solutions to your problem, but I think my example is pretty basic and the concept should be easy to grasp.

Stoffel
01-29-2003, 02:15 PM
Hiya

Ok, I tried to use your method

(calculate() is a function i guess

But, my functions are called calculate(f) (for example)
So how can I use your method?