10 Replies Latest reply on Feb 8, 2018 9:18 AM by Thom Parker

    Acrobat X Pro calculation problem

    peanutmom

      I have an order form which has six items for sale. The first field on each item is the number of items the customer is purchasing. The second field is a hidden field which creates the cost of the item. The third field is simply first field + second field = total cost for that item.  There are another five lines of exactly the same code. The problem comes in with the final Grand Total line. I wasn't able to simply perform a sum function and pick my fields. I had to do a custom calculation.  It works. However, if the person picks something from line one and skips to line three, the grand total turns into a mess.

       

      Examples:

      Field One (how many, limited to three characters - a/k/a "order.0.0")

      Field Two (hidden - validate value of 75 to 75, or whatever each line costs - a/k/a "cost.0.0")

      Field Three (custom calculation script):

      var a = this.getField("order.0.0")

      if(a.value!=0)

      event.value = a.value * 75

      else

      event.value = ""

       

      Each line is assigned a different variable, and the "a.value" changes to whatever the publication costs. Customer needed the if/else statement to keep the zeroes out of the way if nothing was ordered.

       

      The final "grand total" calculation is done this way:

      var a = this.getField("price.0.0");

      var b = this.getField("price.1.0");

      var c = this.getField("price.2.0");

      var d = this.getField("price.3.0");

      var e = this.getField("price.4.0");

      var f = this.getField("price.5.0");

      event.value = a.value + b.value + c.value + d.value + e.value + f.value;

       

      All works fine as long as no fields are skipped. Otherwise, $75.00 + $120.00 ends up being $75,120.00 instead of the actual $195.00. I am not a programmer; is there something else I am missing? Thank you!