4 Replies Latest reply on Aug 3, 2016 4:43 PM by Monteigo99

    How to script: If (field 1 through 5 ="N/A") event.value="N/A"

    Monteigo99 Level 1

      I'm
      still learning and have a script as follows:

      var
      totalY = 0; 

      var
      total = 0; 

      for

      var totalY = 0; 

      var total = 0; 

      for (var i=1; i<=5; i++) { 

          var f = this.getField("JDCRDropdown"+i); 

          if (f.valueAsString=="Y") { 

              totalY++; 

              total++; 

          } else if (f.valueAsString=="N") { 

              total++; 

          } 

      if (total==0) event.value = "N/A"; 

      else event.value = totalY + " of " + total;

       

       

      The
      problem is that and N/A is different than zero of zero. If I leave as is, then the output field defaults to N/A. If I remove: if (total==0) event.value = "N/A";  then it spits out 0 of 0 as the default. What I need is for it to default to 0 of 0, UNLESS all 5 fields are N/A. Then I need the output to be N/A.

       

      ALL 5 fields must have N/A selected in order for it to populate N/A.

       

      I've attempted a few different scripts to no avail.

       

      Thanks