• Resolved Javy26

    (@javy26)


    Was wondering if using the drop down in this scenario is possible.

    Let’s assume the drop down is populated with the values: jewellery, clothing, computer part.

    We have two other fields, the field where the user inputs(let’s call it field 1) and also where the result is generated(let’s call this field 2).

    And the drop down we will refer to it as field 3.

    What I want is something like this:

    1. Value for field 1 is entered
    2. Field 2 value is determined for eg. by this calculation: if field 3 is jewellery then field 1 is equated to field 1*2.

    Is this possible?

    Regards,

    Jevon

    https://ww.wp.xz.cn/plugins/calculated-fields-form/

Viewing 1 replies (of 1 total)
  • Plugin Author codepeople

    (@codepeople)

    Hi,

    Yes, of course, you can use conditional statements in the equations, there are different ways, for example, all the equations below, associated to the calculated field you will return the same result:

    Using the operation “IF”:

    IF( fieldname3 == 'jewellery', fieldname1*2, fieldname1)

    Note: javascript is a programming language case sensitive, do not confuse the operation “IF” implemented by the plugin, with the conditional statement “if” in javascript.

    Using the ternary operator in javascript:

    ( fieldname3 == 'jewellery' ) ? fieldname1*2 : fieldname1

    Using the conditional statement in javascript:

    (function(){
    if(fieldname3 == 'jewellery') return fieldname1*2;
    else return fieldname1;
    })()

    Best regards.

Viewing 1 replies (of 1 total)

The topic ‘Drop Down Calculation’ is closed to new replies.