5 Replies Latest reply on Sep 22, 2015 11:53 AM by Sean.twyman

    Field Validation Calculate error

    Sean.twyman Level 1

      I have a form that I am trying to calculate the value of multiple fields based on one fields entry... Here is my JavaScript

       

      (function () {
      // Get the value entered in this field, as a number
      var yttl = +event.value;
      // Get references to the other fields
      var ilvl = getField("IncLvl");
      var ilft1 = getField("IncLeft1");
      var ilvl1 = getField("IncLvl1");
      var ilft2 = getField("IncLeft2");
      var ilvl2 = getField("IncLvl2");
      // If the field is blank, set the other fields to blank
      if (!event.value) {
          ilft.value = "";
          ilvl.value = "";
          return;
      }
      // Set the other field values
      if (yttl < 500) {
          ilvl.value = "0";
          ilvl1.value = "1";
          ilft1.value = 500 - yttl;
          ilvl2.value = "2";
          ilft2.value = 2000 - yytl;
      } else if (yttl >= 500 && yttl < 2000) {
          ilvl.value = "1";
          ilvl1.value = "2";
          ilft1.value = 2000 - yttl;
          ilvl2.value = "3";
      } else if (yttl >= 2000 && yttl < 5000) {
          ilvl.value = "2";
          ilvl1.value = "3";
          ilft1.value = 5000 - yttl;
          ilvl2.value = "4";
      } else if (yttl >= 5000 && yttl < 10000) {
          ilvl.value = "3";
          ilvl1.value = "4";
          ilft1.value = 10000 - yttl;
          ilvl2.value = "5";
      } else if (yttl >= 10000 && yttl < 15000) {
          ilvl.value = "4";
          ilvl1.value = "5";
          ilft1.value = 15000 - yttl;
          ilvl2.value = "N/A";
      }
      }())
      

       

       

      Everything seems to work fine except for line 22. i keep getting an error that "yytl" is not defined. I don't see the reason why i am getting that error. can someone please assist me.