• Resolved More

    (@wilsonmorema)


    Hello Coders,

    I am working on a logistics website, I need to get a calculated field based on a selection of two drop down options. I was thinking of maybe how to use AND on such equation (fieldname x==’Male’?0.90:0.85).

    Please help.

    Thanks

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

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

    (@codepeople)

    Hello,

    You can use a piece of code very similar to the code you’ve included in your ticket. Assuming the field with the genre is the fieldname1, the equation could be implemented as:

    Using the ternary javascript operator:

    
    (fieldname1=='Male') ? 0.9 : 0.85
    

    Using the “IF” operation distributed with the plugin:

    
    IF(fieldname1=='Male', 0.9, 0.85)
    

    Implementing the equation with a structure of function, and the conditional statement “if” (javascript is a case sensitive language, please, do not confuse the “IF” operation distributed with the plugin, with the javascript conditional statement “if”):

    
    (function(){
    if(fieldname1 == 'Male') return 0.9;
    return 0.85;
    })()
    

    Best regards.

    Thread Starter More

    (@wilsonmorema)

    Hello

    Thank you for the prompt response never expected it to be that prompt. But there is something i have not got clear.. Sorry to ask again but i have attached an example of what i need help

    DESTINATION KENYA TANZANIA UGANDA

    FROM
    DUBAI $7 $9 $9
    TURKEY $8 $10 $10
    INDIA $10 $12 $12

    I need it in such a way if user selects from either drop down options dubai,turkey or india and destination either of the three then he is able to get the summation.

    Please any help will be highly appreciated.

    • This reply was modified 5 years, 11 months ago by More.
    • This reply was modified 5 years, 11 months ago by More.
    Plugin Author codepeople

    (@codepeople)

    Hello @wilsonmorema

    In this case you should include multiple conditional statements as part of the same equation. I will try to describe the process with a hypothetical example:

    
    (function(){
    var first = fieldname1, second = fieldname2;
    if(AND(first == 'A', second == 'B')) return 12;
    if(AND(first == 'A', second == 'C')) return 23;
    if(AND(first == 'B', second == 'C')) return 34;
    })()
    

    As you can see, I’m checking every possible pair of values in the fields. Now, you can adjust the hypothetical example to your fields, values and prices.

    I’m sorry, but the support service does not include the implementation of the users projects (forms or formulas). If you need additional help implementing your project, I can offer you a custom coding service, from my private website:

    https://cff.dwbooster.com/customization

    Best regards.

    Thread Starter More

    (@wilsonmorema)

    Thanks so much, you are a lifesaver. That helped me a lot.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Get a calculated field based on two drop down Options’ is closed to new replies.