CalcBuilder Forum

price calculator

User moon_862 2013-01-09 17:55:08

I need help with the calculation. I need to have the product between Prezzo and Qta as totale (for several voices) then I need to calculate the global total.
So I have these fields:
Voices, Price, Qta, Total(Price*Qta)
and then the global Total.
The Price values are defined by the administrator of the site, the qta are input by the user.
The form should be like a table with four colums and the Global Total as final calculation.
May you give me some advice?
Thanks Marco
If you want you can contact me at

Edited by MSTeam - 09.01.2013 18:16

Moonsoft support 2013-01-09 18:30:57

Hello,
this can be done with this simple code. Let's say you named your input fields this way:

qta1
qta2
qta3
qta4

At the code section, you will need something like this:

\$price1=37;
\$price2=38;
\$price3=39;
\$price4=40.15;

//this are the configurable prices.And then we'll calculate subtotals:

\$subtotal1=\$qta1*\$price1;
\$subtotal2=\$qta2*\$price2;
\$subtotal3=\$qta3*\$price3;
\$subtotal4=\$qta4*\$price4;

//all subtotals added together, will do the final total

\$total=\$subtotal1+\$subtotal2+\$subtotal3+\$subtotal4;

Now you can configure your output at the output layout, you can print any input, intermediate of final result inside the output html, using ##total## sintax. You can try this for the output:

You inserted at qta1 field the value ##qta1## and the result of the line is ##subtotal1##. The total is ##total##

You can arrange your results as needed using the output editor.

Hope this helps, regards

User moon_862 2013-01-14 12:18:37

Thanks for this advice. I would need something different: the administrator writes the voices and the prices of the form/database and the user select the qta and has the subtotal and the total. In this way the price field must be readonly for the user. I think if it is possible to use 2 sections, one for the admin and the other one for the user. The problem is how and is it possible to save the voices and the prices values in a database and recall them on the 2 section for the user?
Let me know if it is possible or too difficult.

Moonsoft support 2013-01-15 09:56:33

Hello,
with the solution we gave you the admin would write the voices and prices from the backend, using form layout, that way user would see prices as plain text. The prices would be constants for the calculator code, so they would be used also there to calculate prices and show the results (but below the form).

But if you want to get rid of the calculate button and show the results inline the input form, or even create a dynamic input table (for example the admin can create a option list from backend with texts/prices, that input list be included at form layout (hidden), and perform some js code that turns that options into a full functional table with texts/prices/input fields and dynamic results). All can be done with calcbuilder, but you will need at least an average level of javascript to get that result.

If you want us to build that kind of code, please note we also have available a custom calculator service, for which we send the calculator ready to import. Think your calculator would fit into standard service quote, if you let us know which is your preferred approach, we'll confirm that if you are interested.

Thank you, best regards

List Manager

Build different lists for your site

CalcBuilder

Create dynamic calculators