5 Replies Latest reply on Feb 3, 2014 10:30 AM by meljar

    Conditional If/Else statement

    meljar Level 1

      I have a text field that calculates a numerical value (AUDITC Total) and a group of Radio buttons for Gender (Male, Female). I want the following conditions to apply:

       

      1. If the person is male and their AUDITC Total score is greater than or equal to 4, I want a "Yes" to entered into another text field (Screen). If the AUDIT score is less than 4, I want a "No" to be entered into the Screen textfield.

       

      2. If the person is female and their AUDITC Total score is greater than or equal to 3, I want a "Yes" to be entered into the Screen text field and if the AUDIT score is less than 3 I want a "No" to be entered into the Screen textfield.

       

      I have entered the following code into the custom calculation area of the Screen text field box and it worked initially. I clicked Male and had a 3 as the AUDIT score, the Screen textfield came up with a "No". However, when I changed the value from Male to Female (AUDIT score was still 3), the Screen text field didn't change from No to Yes. I think I'm on the right track, but maybe there is a better way to do this, or something else is wrong)?

       

       

      var v = this.getField("AUDITC Total").value;

      var g = this.getField("gender 1").value;

       

       

      if (v=="Off" && g=="Off") event.value = "";

       

       

      else if (g=="Male" && v<"4") event.value = "No";

       

       

      else if (g=="Male" && v=>"4") event.value = "Yes";

       

       

      else if (g=="Female" && v<"3") event.value = "No";

       

       

      else if (g=="Female" && v=>"3") event.value ="Yes";