WordPress.org

Ready to get started?Download WordPress

Forums

Calculated Fields Form
[resolved] Max - Min (10 posts)

  1. oligou
    Member
    Posted 11 months ago #

    Hello,

    I have this ;

    (function(){
    if(fieldname11=='Male')
    return (5.5+(fieldname6-95)*0.1);
    if(fieldname11=='Female')
    return (5.5+(fieldname6-96)*0.1)
    })()

    It's working, but I would in any case, have a min of 5% and a max of 8%

    Is it possible without extending this formula by using min and max ?

    thank you !

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

  2. codepeople
    Member
    Plugin Author

    Posted 11 months ago #

    Hi,

    I don't understand what you need to do with the min and max in that case. Please provide a sample or more info.

    Thank you!

  3. oligou
    Member
    Posted 11 months ago #

    I don't know if min-max are suitable in this case ... just an idea

    the coutcome of my fonction if, should never be min 5% or higher 8%

    I know I can put another If, but too complicated ...

    Is that clear now ?

  4. codepeople
    Member
    Plugin Author

    Posted 11 months ago #

    Ok, this may work:

    (function(){
    if(fieldname11=='Male')
    return max(min(5.5+(fieldname6-95)*0.1,8),5);
    if(fieldname11=='Female')
    return max(min(5.5+(fieldname6-96)*0.1,8),5)
    })()

    The use of the function is basically this one:

    max(min(VALUE,8),5)

    ... that guarantees that if VALUE is between 5 and 8 that value will be returned. If it's higher than 8 then 8 will be returned and if it's smaller than 5 then 5 will be returned.

    Hope that helps.

  5. vortexintercom
    Member
    Posted 10 months ago #

    Hi.

    function(){
    if(fieldname4=>50)
    return prec((((fieldname2*(39.2+3))-(fieldname2*((100-fieldname4)/100)*fieldname6))/(fieldname2*fieldname4/100))*1.1082,2)
    })()

    It doesn't work. Where is my mistake? Thanks.

  6. codepeople
    Member
    Plugin Author

    Posted 10 months ago #

    Hi,

    First, the comparison symbol is >=, and not =>

    Second, is not present the ( symbol at beginning of equation.

    So, the correct equation format would be:

    (function(){
    if(fieldname4=>50)
    return prec((((fieldname2*(39.2+3))-(fieldname2*((100-fieldname4)/100)*fieldname6))/(fieldname2*fieldname4/100))*1.1082,2);
    })();

  7. anefarious1
    Member
    Posted 8 months ago #

    Hello,

    How can the prec feature be added to the help you provided in this tread earlier. Here is what I'm referring to:

    (function(){
    if(fieldname11=='Male')
    return max(min(5.5+(fieldname6-95)*0.1,8),5);
    if(fieldname11=='Female')
    return max(min(5.5+(fieldname6-96)*0.1,8),5)
    })()

    The use of the function is basically this one:

    max(min(VALUE,8),5)

    Where would the PREC go? Thanks

  8. anefarious1
    Member
    Posted 8 months ago #

    To put it more simply, how to combine prec with min or max? It doesn't seem to work the way I thought it would. thanks

  9. @anefarious1 If you need assistance then per the forum welcome please post your own topic.

    http://wordpress.org/support/plugin/calculated-fields-form#postform

  10. codepeople
    Member
    Plugin Author

    Posted 8 months ago #

    Hi,

    The process is simple, suppose your equation is max(fieldname1,5) to get the max number between the value of fieldname1 and five, but you need the result with two digital numbers. So the equation would be:

    prec(max(fieldname1,5),2)

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.