• Resolved Jimmy

    (@jayem82)


    Hello again!

    In one of my dropdowns <%fieldname11%>, I have five different options:

    [Text] Choose one… [Value] 0
    [Text] First option [Value] firstoption
    [Text] Second option [Value] secondoption
    [Text] Third option [Value] thirdoption
    [Text] Fourth option [Value] fourthoption

    I need those text values to stay intact for later use, but I also need a calculated field to turn those text options into regular values like so:

    IF fieldname11 is value 0 return ‘Please make an option’
    IF fieldname11 is value firstoption OR secondoption return 10
    IF fieldname11 is value thirdoption OR fourthoption return 20

    Cheers!

    https://www.ads-software.com/plugins/calculated-fields-form/

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

    (@codepeople)

    Hi,

    You can use conditional statements in the equations, as follows:

    (function(){
    var v = fieldname11;
    if( v == 0 ) return 'Please make an option';
    if( v == 'firstoption' || v == 'secondoption' ) return 10;
    return 20;
    })()

    Other options are:

    Using the “IF” operation:

    IF( fieldname11 == 0, 'Please make an option', IF( fieldname11 == 'firstoption' || fieldname11 == 'secondoption', 10, 20 ))

    or using the ternary operator of javascript:

    ( fieldname11 == 0 ) ? 'Please make an option' : (( fieldname11 == 'firstoption' || fieldname11 == 'secondoption' ) ? 10 : 20 )

    Best regards.

    Thread Starter Jimmy

    (@jayem82)

    Again, thank you!

    It surprises me how fast you are, and that you spend time on supporting the free version of the plugin in this way. The day before christmas eve of all days ??

    Premium support indeed.

    Merry Christmas!

    Plugin Author codepeople

    (@codepeople)

    Thank you! Merry Christmas!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Converting text values to real values’ is closed to new replies.