• Resolved a.deghiedy

    (@adeghiedy)


    Hi, i would like to implement the following scenario:
    1. I have fieldname1 as a drop down list with three choices Over 25, 21-24 and 18-20
    2. I have another field lets say fieldname2 that has a calculation that comes up with specific results.
    3. I want to have a condition that says:
    a. If “Over 25” is selected from fieldname1 AND the fieldname2 > 7.25 return the message “You are allowed” if fieldname2 < 7.25 return the message “You are not allowed”

    b. If “21-24” is selected from fieldname1 AND the fieldname2 > 9.25 return the message “You are allowed” if fieldname2 < 9.25 return the message “You are not allowed”

    c. If “18-20” is selected from fieldname1 AND the fieldname2 > 11.25 return the message “You are allowed” if fieldname2 < 11.25 return the message “You are not allowed”

    Is it possible and if possible how can i achieve that?

    Thanks

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

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

    (@codepeople)

    Hi,

    I’ve some recommendations. Please, use as the values of the choices in the Drop-Down field the letters: A, B, and C, corresponding to the texts: Over 25, 21-24 and 18-20, respectively.

    And the equation would be as simple as:

    (function(){
      var f1 = fieldname1, f2 = fieldname2;
      switch(f1)
      {
        case 'A':
          return IF(f2>2.75,  'You are allowed', 'You are not allowed' );
        break;
        case 'B':
          return IF(f2>9.25,  'You are allowed', 'You are not allowed' );
        break;
        case 'C':
          return IF(f2>11.25,  'You are allowed', 'You are not allowed' );
        break;
      }
    })()

    and that’s all.

    In reality the support service does not include the implementation of the users projects, however if you need additional help, we can offer you a custom coding service through our website:

    http://cff.dwbooster.com/customization

    Best regards.

    Thread Starter a.deghiedy

    (@adeghiedy)

    Thanks for that.

    Should i add that in a calculated field or HTML field? as i tried to add it in the equation part in a calculated field but the field stays empty and no messages is getting returned.

    Appreciate your help.

    Plugin Author codepeople

    (@codepeople)

    Hi,

    The code should be inserted in the equation editor associated to the calculated field, however be sure the fields names and values were inserted correctly in your form.

    Best regards.

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

The topic ‘Help with a calculation’ is closed to new replies.