3 Replies Latest reply on Jul 2, 2009 7:45 AM by VDivgi

    conditional calculation

    VDivgi

      Hi,

       

      I am using Adobe Acrobat 5.0 to preparing a tax return form.

       

      I have to fields - 1. Total tax payable and

                              2. Total reliefs which is the sum of four fields (for simplicity lets take them as Relief 1, Relief 2, Relief 3 and Relief 4).

       

      I want your help in writing a custom script which will achieve the below:

       

      a) if Total tax is less than/equal to total relief, then the total relief should be restricted to total tax. for example if total tax is $1000 and the total relief is $1200, then $1000 should appear in the Total relief field.

       

      b) else the sum of all the reliefs should appear in the Total relief field. for example if total tax is $1000 and the total relief is $800, then $800 should appear in the Total relief field.

       

      Many thanks for your help.

       

      Regards,

       

      Vijay

        • 1. Re: conditional calculation
          MarkWalsh Level 4

          Do you want to show the minimum value between the two? If so, this should do what you want.

           

          Create your two fields 'totalTaxPayable' and 'totalReliefs' and set the totalReliefs field to calculate your totals from Relief.1, Relief.2, etc. You can hide the totalReliefs

           

          Then create a third field to display the min value, call it 'totalReliefsDisplay' and put this in the custom calculation script:

           

           

          event.value = Math.min(this.getField("totalTaxPayable").value, this.getField("totalReliefs").value)

          1 person found this helpful
          • 2. Re: conditional calculation
            MarkWalsh Level 4

            Since using the minimum value might not be what you want, this should work for the calculated field:

             

            var totalTax = this.getField("totalTaxPayable").value

            var totalRelief = this.getField("totalReliefs").value

             

            if (totalTax < totalRelief) {

            event.value = totalTax

            } else {

            event.value = totalRelief

            }

            • 3. Re: conditional calculation
              VDivgi Level 1

              Hi Mark,

               

              Thanks a lot for your time. This option works perfect for me.

               

              Regards,

               

              Vijay