WordPress.org

Ready to get started?Download WordPress

Forums

Calculated Fields Form
[resolved] Changing the rounding off function (4 posts)

  1. Dean
    Member
    Posted 9 months ago #

    the contact form enables one to round off but what if i wanted to set my own rounding off parameter.
    this are the current conditions
    If the value of the passed parameter is greater than or equal to x.5, the returned value is x+1; otherwise the returned value is x.

    what if i wanted for instance, if the value is 2680 it rounds it off to 2700. if its 2630 it rounds it off to 2650.

    http://wordpress.org/plugins/calculated-fields-form/

  2. codepeople
    Member
    Plugin Author

    Posted 9 months ago #

    Hi,

    In this case the equation will be a little more complex that usual. For example, suppose that original equation is fieldname1+fieldname2, if you want to use an uncommon operation for rounding the result, you should transform the previous equation like follow:

    (function(){
    var r = fieldname1+fieldname2;

    if(r == 2680) r = 2700;
    if(r == 2630) r = 2650;

    return r;
    })();

  3. Dean
    Member
    Posted 9 months ago #

    so i should insert all that where? in the equation field? and i want it to do that for every value that is calculated. is it possible?
    thank you for your prompt response.

  4. codepeople
    Member
    Plugin Author

    Posted 9 months ago #

    Hi,

    The demo in the previous entry, should be entered in the equation field. But pay attention, it is only a demo to demonstrate how to define a equation more complex.

    You may create complex equations in all Calculated Fields.

Reply

You must log in to post.

About this Plugin

About this Topic