6 Replies Latest reply on Nov 23, 2009 5:37 PM by QuiG0n

    Forms,custom calculation script.


      First, I'm very much a zero in programming anything.

      I want to combine simple math in a PDF form.

      I basically have many of these type of combined forms I wanna calculate using a set value which is not set to a field.

      Can I use the javascript function calculating this? And how?

      Field named A : field B * a set value = field C

        • 1. Re: Forms,custom calculation script.
          gkaiseril MVP & Adobe Community Professional

          Yes, you can see how to do some simple calculations by reading How to do (not so simple) form calculations by Thom Parker. It is possible to write a 'Sum()' function, but that would require accessing more features of Acrobat.

          • 2. Re: Forms,custom calculation script.
            try67 MVP & Adobe Community Professional

            You don't need any JavaScript for this.

            Go to the field's Properties, Calculate tab. Select Simplified field notation and enter the name of the other field * the set number. So if the other field is called Text2 and you want your field to be 5 times that, enter:

            Text2 * 5

            1 person found this helpful
            • 3. Re: Forms,custom calculation script.
              QuiG0n Level 1

              Yes, helpful, and I tried a little on that field earlier. I got a simple "FieldA * 60" to work ,

              but struggled with others. Then I discovered that the field names can't contain spaces in the simplified field notation.

              So now I got it to work so far. Thanks for bringing me onto that track again.

              • 4. Re: Forms,custom calculation script.
                QuiG0n Level 1

                I have another BIG problem with the calculations.

                When I choose 0 decimals, and the calculations results in a 24,4568 answer,

                these Javascript warning boxes appear telling me bla bla bla.

                Can I somewhere turn those warnings off?

                Or is there another way to work around this?

                Because having to tic off those boxes all the time ruins the flow of the document.

                I thought I crossed the finish line,but no.. so close,sooo close   

                Yet another thing, is it possible to not have the document automatically calculate in real time.

                To have the calculations done only as you move from field to field?

                • 5. Re: Forms,custom calculation script.
                  gkaiseril MVP & Adobe Community Professional

                  A lot of form actions are triggered by very specific events in working with a form field. Calculations usually occur after the 'keystroke' or 'selection' is completed and before exiting the field, but with coding JavaScript you could perform the calculation with each keystroke, if you are using a combo box you need to set 'commit on selection' option. This information is documented in Adobe's Acrobat JS API Reference. My previous linked article has a link to this PDF, and it also explained about the non-custom JavaScript options for calculations.

                  • 6. Re: Forms,custom calculation script.
                    QuiG0n Level 1

                    I have gone through the linked article and many others.

                    But I haven't found anything specific that relates to the problems I have right now.

                    Which are these error boxes that pops up warning me about format errors in certain fields,

                    related to decimals in calculations.

                    I have set all fields to 0 decimals for them to be practical.

                    Apart from that all my simplified calculation scripts work perfect together with the calculation presets.

                    So again, I need a way to work around decimals in the scripts, or a way to turn off those error warnings.