6 Replies Latest reply on Jan 19, 2018 4:57 PM by gkaiseril

    Having trouble with result not changing if another number is added into the equation....

    stepheng54012748 Level 1

      Hello Friends,

       

      Thank you in advance for helping me learn Javascript!  If anyone has any advice on my current issue that would be fantastic.  I hope I can explain this so it's understandable.  Here are the scenarios:

       

      Cell D = L16

      Cell E = L17

      Cell F = L18

      Cell H = L20

      Cell I = L21

      Cell J = L22

       

      Example:  If $10,000 is entered in Cell D, $250 is entered in Cell E, $250 is entered in Cell F, I've written script that limits the entry into Cell F to 1.5%.  Cell J will automatically be $10,000.  Here is my script which works!  The result is $150.

       

      var a = this.getField("L22").value;

      if (event.value > a * .015)event.value=(event.value = a * .015);

      else event.value;

       

      if (event.value) event.value = util.printf("%.4f", event.value);

       

      The issue happens when I enter an amount into Cell H (example $5,000).  It is supposed to reduce Cell J.  So, the original amount of $10,000 will reduce by $5,000 with a new result of $5,000.  Cell F should reduce down to $75.00.  The problem is it doesn't reduce.  It stays at $150.  If I go back to Cell F and enter $250 again then it calculates down to $75.  I am stumped how to write so it changes if a number is entered into Cell H and/or Cell I.