• Resolved Ditz80

    (@ditz80)


    Hi and thanx for this useful device.
    I’ve a little question about the Javascript code you suggest on this page:

    (function(){

    if(fieldname3 > 100) return fieldname1+fieldname2;

    if(fieldname3 <= 100) return fieldname1*fieldname2;

    })();

    This one works fine, but I need a code to insert a third range rule about a return for a value included between two limits. I mean:
    1) <= 10
    2) 10 < x < 20
    3) => 20.

    Can you help me? Thanx a lot!

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

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

    (@codepeople)

    Hi,

    You only should extend the same logic of previous equation, to a third conditional statement, like follow:

    (function(){

    if(fieldname3 <= 10) return 10;
    if(10 < fieldname3 && fieldname3 < 20) return 15;
    if(20 <= fieldname3) return 20;

    })();

    Note: the return values are only for demo.

    Thread Starter Ditz80

    (@ditz80)

    Thanks a lot, it works!

    I didn’t know the use of “&&”…

    Have a nice,
    Paolo

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Little question about Javascript’ is closed to new replies.