• Resolved mira404

    (@mira404)


    Hi, I try to build a calculator that has 2 Dropdown fields.

    1st field is called: Club
    2nd field is called: Lie

    Like this: https://prnt.sc/ucv7ie7jnSoX

    Lie have fixed value (-4, -3, -2, -1, 0, 1, 2, 3, 4).

    Club = dropdown field and it’s has 9 different values for each club. Like wood has 9 different values and also wedge has 9 different values.

    Wood: (0.40, 0.42, 0.32, 0.33, 0.30, 0.31, 0.43, 0.39 and 0.34)
    Wedge: (0.45, 0.40, 0.37, 0.35, 0.32, 0.31, 0.43, 0.39 and 0.37)

    So I need to put 9 club values for each club, like Wood, Wedge, etc.

    For Example:

    1. Select Club= Wood (0.40) and Lie: -4
    2. Select Club= Wood (0.42) and Lie: -3
    3. Select Club= Wood (0.32) and Lie: -2
    4. Select Club= Wood (0.33) and Lie: -1
    5. Select Club= Wood (0.30) and Lie: 0
    6. Select Club= Wood (0.31) and Lie: 1
    7. Select Club= Wood (0.43) and Lie: 2
    8. Select Club= Wood (0.39) and Lie: 3
    9. Select Club= Wood (0.34) and Lie: 4

    Formula: PREC((club * lie), 1)

    How to set up these calculator club values?

    Please check the Link to the page you need help with I would build to like that calculator.

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @mira404

    There are different possible implementations to the equation. For example, you can use if conditional statements:

    (function(){
        var club = fieldname1, lie = fieldname3, v;
    
        if(club == 'Wood')
        {
            switch(lie){
                case -4: v = 0.40; break;
                case -3: v = 0.42; break;
                case -2: v = 0.32; break;
                case -1: v = 0.33; break;
                case 0: v = 0.30; break;
                case 1: v = 0.31; break;
                case 2: v = 0.43; break;
                case 3: v = 0.39; break;
                case 4: v = 0.34; break;
            }
        }
        if(club == 'Wedge')
        {
            /* include the switch block corresponding to the Wedge club */
        }
        return PREC(lie*v, 1);
    })()

    Best regards.

    Thread Starter mira404

    (@mira404)

    Thanks a lot!

    I have almost complete the calculator but I have one more thing:

    If I select the negative value (-) as an input, the output comes to negative then I want to show Increased by [Output]. Like this: https://prnt.sc/t_5EgfA3xPA7

    If I select the positive value (+) as an input and the output comes to positive, I want to show Decrease by [Output]. Like this: https://prnt.sc/_GXRVowmcOdU

    How to do this?

    Plugin Author codepeople

    (@codepeople)

    Hello @mira404

    You can edit the following piece of code in the equation:

    return PREC(lie*v, 1);

    as follows:

    return IF(lie*v<0, 'Increased by ', 'Decreased by ') + PREC(lie*v, 1);

    Best regards.

    Thread Starter mira404

    (@mira404)

    It’s working. Now show “Increased by” and “Decreased by” so I don’t need to show (-) symbol how to remove this? Check: https://prnt.sc/vFEtZPV8E-ao

    This result is shown in inches.

    As well as have a centimeter field and the formula is PREC((fieldname9*2.54), 1) but How I can add “Increased by” and “Decreased by” to this field.

    Also check this: https://prnt.sc/Z3ojyJaMGVl0

    Plugin Author codepeople

    (@codepeople)

    Hello @mira404

    You can use the ABS operation to get always the positive value:

    return IF(lie*v<0, 'Increased by ', 'Decreased by ') + PREC(ABS(lie*v), 1);

    Please, note the support service does not cover the implementation of the users’ projects. We cannot implement your project through the WordPress forum.

    If you need that us to implement your project, you can contact us through the plugin’s website: Custom Coding Service

    Best regards.

    Thread Starter mira404

    (@mira404)

    Thanks a lot! I solve that

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Multiple Value Cal.’ is closed to new replies.