11 Replies Latest reply on Apr 29, 2015 11:24 AM by try67

    Javascript for forms

    Chris Hembel Level 1

      I am trying to get this form to calculate a product. I need the read only field which will calculate to be empty when there is nothing to calculate against. I am calculated the Late Fee Price by the Late Fee Quantity. The Quantity is the field that will get changed by the person filling out the form. Then I want the total field to show the cost and it will then be added to the other totals in the column and other field will calculate with that amount.

       

      The form in Preview looks like this:

      Capture2.JPG

       

      The two white fields are calculated fields that need to be empty so that if a user wants to print and fill in by hand, there is a space for them to write in.

       

      In Edit Mode my form looks like this:

      Capture3.JPG

       

      My Script for the "US_LateFeeSubTotal" blank field is:

      var A = this.getField("LateFeeQuantity").value;
      var B = this.getField("LateFee").value;

      if( A > 0 ) event.value = A * B;
      else event.value = "";

       

      I have both the "LateFeeQuantity" and "US_LateFeeSubTotal" fields set as Number Format. Obviously, I have the one set to 0 decimal places and the other one set to 2 decimals with a $ preceding the calculated amount.

       

      When I go to the Preview mode and type in a 1 in the "LateFeeQuantity" field I get the following error:

      Capture.JPG

      What I am wondering is if I need to change my formula from "A>0" to something like "A!=""" or in other words if "A is not null" I just don't know what the syntax is or if that is really what my problem is.

       

      Any help or suggestions would be greatly appreciated.