• Resolved matt130190

    (@matt130190)


    IF(fieldname12 == ‘Metric’) return ‘False’;

    Fieldname 12 is a radio button with Metric & Imperial options why is this not returning False when metric is selected ??

    I’ve tried setting the value of Metric to 1 and imperial to 2 but this still does not work.

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

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter matt130190

    (@matt130190)

    Just to summarize eventually I would like

    If metric selected calculate (Lxwxh)/1000 to get volume in liters
    If I imperial do (((l*w*h)*2.54)/1000)

    Plugin Author codepeople

    (@codepeople)

    Hello @matt130190

    You are confusing the operation “IF” distributed with the plugin, and the “if” conditional statement of javascript (remember that javascript is a case sensitive programming language)

    For example, assuming you want to return the text False if fieldname12 value is Metric and the text True in other cases.

    Using the “IF” operation distributed with the plugin:

    
    IF(fieldname12 == 'Metric', 'False', 'True')
    

    Pay attention, the “IF” operation requires three parameters: condition, operations if the condition is true, and operations if the condition is false.

    Now the same equation using the javascript conditional statement “if”. In this case you require to implement the equation with function structure:

    
    (function(){
    if(fieldname12 == 'Metric') return 'False';
    return 'True';
    })()
    

    A third alternative using the ternary javascript operator:

    
    (fieldname12 == 'Metric') ? 'False' : 'True'
    

    Best regards.

    Thread Starter matt130190

    (@matt130190)

    Hi

    Thank you for your quick reply unfortunately it’s still not working 🙁 I’m not sure if this will work but please see photos below

    Photos

    It doesn’t seem that radio button is being recognized

    Thanks so much in advance

    So in theory it should display false unless metric is selected then display true

    • This reply was modified 7 years, 6 months ago by matt130190.
    Plugin Author codepeople

    (@codepeople)

    Hello @matt130190

    In the equations you always use the values of the fields and not the texts of the choices. The checkbox: “Value to submit” only affects to the value to submit and not to the equations, so, the equation would be:

    
    (function(){
    if(fieldname12 == 'X') return 'False';
    return 'True';
    })()
    

    Best regards.

    Thread Starter matt130190

    (@matt130190)

    Yay is now working, thankyou so much 🙂

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Help with Radio Button’ is closed to new replies.