• Resolved davidpokorny

    (@davidpokorny)


    Hi there, is there a chance how to create if statements for the inputs?
    Like so:
    If an input is X show the result Y
    If the input is between the range A – B show result Z

    Hope it makes sense!
    Thank you

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter davidpokorny

    (@davidpokorny)

    So, I’ve just found out how to create if statements. I’m struggling with the “return” feature.
    Can I return a certain number rather than 2*fieldname1?
    For example
    If the input is from 5 to 10 I need to display “100” if the input is from 11-200 I need to display “250”.
    Thank you

    Plugin Author codepeople

    (@codepeople)

    Hello @davidpokorny

    Yes, of course, and the process is really simple. There are different alternatives.

    Implementing the equation by using function structure:

    
    (function(){
    if(AND(5<=fieldname1, fieldname1<=10)) return 100;
    if(AND(10<fieldname1, fieldname1<=200)) return 250;
    })()
    

    The same equation but nesting “IF” operations instead of “if” conditional statements:

    
    IF(AND(5<=fieldname1, fieldname1<=10), 100, IF(AND(10<fieldname1, fieldname1<=200), 250, ''))
    

    A third alternative by this time using the javascript ternary operator:

    
    AND(5<=fieldname1, fieldname1<=10) ? 100 : (AND(10<fieldname1, fieldname1<=200) ? 250 : '')
    

    Best regards.

    Thread Starter davidpokorny

    (@davidpokorny)

    Great, thank you! All sorted

    Thanks

    Thread Starter davidpokorny

    (@davidpokorny)

    Sorry – follow-up question. If statements work perfectly!
    I just need following:

    I’ve been trying to display the result on the same page but in a different section.

    Is this achievable?

    Thanks

    Plugin Author codepeople

    (@codepeople)

    Hello @davidpokorny

    Please, indicate the URL to the form, and let me know the section where you want to display the result.

    Best regards.

    Plugin Author codepeople

    (@codepeople)

    Hello,

    Given you have not responded to the last question, I assume you have found the solution.

    Best regards.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘If statements’ is closed to new replies.