• Resolved dftee

    (@dftee)


    I have made a pricing calculation form using Caldera Forms. Currently I have problems rounding the numbers or removing all decimals, and would really appreciate any help.

    If it was possible to format the numbers and round the numbers easily, I would pay for the plugin. But for now it does not seem to be possible and I might have to switch to another product.

    Heres what I’ve done:
    Dropdown with products, monthly prices as value. (free, std, pro)
    Dropdown with subscription type (month by month, 1 year, 2 year, 3 year) discount as value.
    Field for typing number of computers.

    I have successfully calculated:
    Total monthly price (product monthly price * number of computers)
    Total monthly price with VAT (Product monthly price * 1,25)
    Monthly discount (Total monthly price * subscription type)
    Total monthly price after discount
    etc…

    But, the problem is that calculated numbers easily get like 8-15 decimals. Does not look good at all. I live in Europe and had to edit thousand separator and decimal separator, that’s supported.. but not the number of decimals.

    So I tried this workaround:
    Hidden field with calculation as value and then using the hidden field in manual formula like this:
    round( %hidden_field% ), but this does not work. It seems that the value of the hidden field does not update/recalculate when other fields changes.

    So using the “normal” method (not Manual Formula) calculated field I get correct value when I do this formula:
    %priv_abo_discount% * %number_pcs% * %product%

    But not when I do the same as value in a hidden field, and then “round( %hidden_field% )” in a Manual Formula in the calculated field. If I could hide the correct calculated field altogether and then round it in another calculated field using manual formula, that would possibly work, but that’s not possible either.

    Please anyone.. How can I get rid of decimals or just round up to nearest number?

Viewing 3 replies - 1 through 3 (of 3 total)
  • This is because caldera doesn’t support Math.round10 javascript function…
    Anyway, I’ve found a “diy” solution works for me.

    We need to convert calculation in manual formula.
    After that, for rounding result and remove decimal i simple use
    round(%your_manual_formula%)

    For rounding x decimal i use
    round(10^x*(%your_manual_formula%))/10^x

    Examples:
    if i need just 1 decimal
    round(10*(%your_manual_formula%))/10x

    for 2 decimals
    round(100*(%your_manual_formula%))/100

    for 3 decimals
    round(1000*(%your_manual_formula%))/1000

    and so on..

    Maybe caldera will support also round10 function one day…
    in meantime i hope this help you.

    • This reply was modified 8 years, 2 months ago by federico.citi.

    Works perfect! Thank you for sharing.

    Just seen the above posts. Can you please explain further how to round and display the result.

    I have 5 figures entered on a Caldera form. I want to show the average of these.

    So I have tried using:

    round((%value1%+%value2%+%value3%+%value4%+%value5%)/5)

    It works fine at the back end when the client receives the form’s email. The email shows the correctly rounded value. But the web page just displays a blank

    The browser console shows ’round’ is undefined.

    Any help would be appreciated. Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Rounding numbers in Caldera Forms’ is closed to new replies.