1 Reply Latest reply on Jul 30, 2013 10:43 AM by mrfale67

    Subtraction Help

    tmist7 Level 1

      I could really use some help with Javascript!

      Here's what I am attempting to accomplish:

      I need 3 fields. The first field needs to subtract to second field and show the answer (or value) in the third field. However, the second field's value must be minus $90.00. Below is my current, non-working script. Please advise!


      var TMIA = this.getField("TOTAL_MONTHLY_INCOME_ALL)");

      var M90 = this.getField("MINUS_90");

      var TAMI = this.getField("TOTAL_AVAILABLE_MONTHLY_INCOME");


      if (TMIA.value != ""){


      TAMI.value = TMIA.value - M90.value;



      event.value = "";

        • 1. Re: Subtraction Help
          mrfale67 Level 2

          This is equivalent to your code but working by me:



          var f1 = this.getField("TOTAL_MONTHLY_INCOME_ALL");

          var f2 = this.getField("MINUS_90");

          if (f1.value && f2.value<90) {

            event.value = f1.value-f2.value;


          else {

            event.value ="";




          However, this code must be placed in TOTAL_AVAILABLE_MONTHLY_INCOME field under validation event and this doesn't make much sense as you should enter a value into that field to execute the script.

          So maybe you should adapt it or use it in a button event. In the latter case, remove "event.value" with f3.value where f3 is this.getField("TOTAL_AVAILABLE_MONTHLY_INCOME");