1 Reply Latest reply on Oct 21, 2011 1:22 PM by George_Johnson

    Need help on calculations in PDF invoice form

    Mary.Betowt

      Hi all, I'm completely stumped.

       

      Here's what I'm trying to do...I have an invoice form with feilds for input of hourly rate, and hours worked. Then I have a totals column with Amounts...that is, hours X rate in the calculations box. Finaly, I have a total box at the bottom that is a calculation of all the Amount boxes added together.

       

      I found a tutorial online to make the 0.00 invisible before any calculations were put in, so I added that into the custom validation spot. It didnt work.

       

      I also find that the Total calculation runs again and again every time I edit a feild. Is there a way to keep calculations from running over and over again? I only want it to run when people input hours/rates into their respective lines.

       

      Here is a link to the file in question: http://dl.dropbox.com/u/1000892/invoice_form_2.pdf

       

      I'm very new to all this, including scripting...any help or guidance would be greatly appreciated. Thanks!

        • 1. Re: Need help on calculations in PDF invoice form
          George_Johnson MVP & Adobe Community Professional

          Replace what you currently have for the validation script of all of the Amount fields and use the following instead:

           

          if (+event.value <= 0) event.value = "";

           

          Note that you won't notice an effect until the calculated field's value changes from zero and then gets set back to zero.

           

          Regarding the recalculation, that's the way automatic recalculations work. If any field value in the form changes, each calculation script is executed, in the order defined by the field calculation order. It's possible to short circuit a calculation by checking which field started the calculation chain, but it's probably not worth it in this case.

           

          Another alternative is to perform the calculation for an Amount field in the validate events of the corresponding Rate and Hours fields. That way, the Amount field will only get updated when either the Rate or Hours field value changes. You would remove the calculation in the Amount field if you take this approach. If you need help with this, post again.

           

          Also, consider correcting the tab order and set it up so it proceeds across the rows rather than down the columns.