CalcBuilder Forum

Display multiple sum results - help needed asap

User moon_1034 2013-04-23 16:42:51

Hi,


I have a calculator that has the following fields..

Hours1
Hours2
Annual Salary


Then in the code I have the following:

$sum=(($hours1+$hours2)/8)*$salary;


This obviously take the two hours divides it by 8 (number of hours in working day) and times it by the salary.

Layout is currently:


Hours1
Hours2
Salary

Sum =


What I want to do is allow the calculator to display an hours1+hours2 sum after the two fields then I want to also introduce another sum display to work out the cost per day (depending on the salary)

So the display would be:

Hours1 (field)
Hours1 (field)

sum display (1+2) =

Salary (field)

Sum display per day =
Sum display per year =



Can you help me with the code and how to do the display please.

Many thanks

Moonsoft support 2013-04-23 17:56:36

Hello,
you can output as many results as you need, only adding more result variables to your code:

$result1=$input1+$input2;

$result2=$result1+5;


so you could print at your output ##result1## and/or ##result2##


The result section is below the form, so it will be always printed after the calculate button. If you need to show intermediate results inside the input form, you will need to add some javascript in order to 'move' a section of the result to other position inside the input layout. Or, include that section of the result inside a hidden div, and once the result is displayed, copy its contents to the new position at the input. You will need:

one destination div at your input layout (id="destination")
one result (hidden) div at your output layout (id="myresult")

some script at the event tab (after calculation), which copies the output to the form.

CB("#destination").html(CB("#myresult").html());

CB is calcbuilder alias for jQuery, you can check any official reference of jquery to get more details.

Hope this helps, regards

User moon_1034 2013-04-25 10:14:59

Okay thanks..will give it a go.

...
List Manager

Build different lists for your site

Buy now!
...
CalcBuilder

Create dynamic calculators

Buy now!