13 Replies Latest reply on Jan 3, 2012 11:27 AM by try67

    Adobe Pro X and JavaScript

    Tonya62

      I have to create a calculating form in Pro using JavaScript. Is JavaScript part of Adobe Pro  If so, how do I use it?

        • 1. Re: Adobe Pro X and JavaScript
          try67 MVP & Adobe Community Professional

          Yes, it is, but there are several built-in functions that you can use

          before resorting to JS, which are much simpler and more intuitive to use.

          Did you have a look at the options under the Calculate tab of the fields

          you want to calculate?

          • 2. Re: Adobe Pro X and JavaScript
            Dave Merchant MVP & Adobe Community Professional

            Forms JavaScript is supported in all versions of Acrobat. With Pro you also have the bundled LiveCycle Designer application, which creates dynamic forms using XFA. AcroForms are simpler to learn and can take their layout from an existing document, but XFA forms can do extra things like automatically add extra pages or reflow content to fit what the user types.

             

            I'd suggest starting off by watching some of the forms and scripting videos on AcrobatUsers.com, in particular the introductions by Thom Parker.

            • 3. Re: Adobe Pro X and JavaScript
              Tonya62 Level 1

              I need a subtraction option. I have 3-columns charge, credit, and

              balance. I need the credit column to subtract from the charge column to

              get a figure for the balance column. I also need a subtotal and total on

              each page and a grand total at the end.

               

               

               

              [personal details removed by forum host]

              • 4. Re: Adobe Pro X and JavaScript
                try67 MVP & Adobe Community Professional

                For totals use the first option under Calculate, "Value is the (sum) of the following fields...", and then select your fields.

                For subtraction use the second option, and simply write the forumla you want to use, like so (in the balance field): 

                credit - charge

                (you have to make sure you're using the exact form fields' names here, and also they may not contain spaces or other special characters)

                 

                Another thing to make sure is that the field calculation order is correct, or you'll get weird results (for example, the grand total should be calculated after the total field).

                • 5. Re: Adobe Pro X and JavaScript
                  Tonya62 Level 1

                  I'm sorry, that does not work. It won't calculate. Is there something

                  else I should try?

                   

                   

                   

                  [personal details removed by forum host]

                  • 6. Re: Adobe Pro X and JavaScript
                    try67 MVP & Adobe Community Professional

                    Did you change the values of the fields after applying the calculation? You

                    need to do it for it to refresh for the first time...

                    If it still doesn't work, you can send me the file to try6767 at gmail dot

                    com and I'll have a look at it for you.

                    • 7. Re: Adobe Pro X and JavaScript
                      Tonya62 Level 1

                      I'm not sure what you mean by "change the values of the fields."  This

                      is the first form I've created that needs calculation, so I have no idea

                      what I'm doing.

                       

                       

                       

                      [personal details removed by forum host]

                      • 8. Re: Adobe Pro X and JavaScript
                        try67 MVP & Adobe Community Professional

                        I mean that it won't kick in immediately. After entering the formula of the

                        desired calculation you need to change the value of one of the fields

                        involved (like from 1 to 2...) to see it in action.

                        • 9. Re: Adobe Pro X and JavaScript
                          Tonya62 Level 1

                          I'm sorry, I still don't understand. What is a "value?" I don't see that

                          option under any of the tabs.

                           

                           

                           

                          [personal details removed by forum host]

                          • 10. Re: Adobe Pro X and JavaScript
                            try67 MVP & Adobe Community Professional

                            The value of the field is simply the text you enter into it (it's not

                            editable via the Properties window).

                            • 11. Re: Adobe Pro X and JavaScript
                              gkaiseril MVP & Adobe Community Professional

                              You may need to change the "Preferences" ("Edit => Preferences => General => JavaScript" or {Ctrl> + K) to enable the use of JavaScript by Acrobat/Reader.

                               

                              This preference will need to be set before you can set a number of field formats or use any of the calculation options. Many of the actions performed by the formatting and optional calculations of the properties for a form field do not appear to use JavaScript, the entered values are processed through JavaScript functions added to Acrobat through a file installed as part of the standard Acrobat install.

                               

                              Have you been able to use a PDF form with calculations?

                              • 12. Re: Adobe Pro X and JavaScript
                                Tonya62 Level 1

                                Thank you for your time today. Unfortunately, I still don't know what

                                you mean by "value of the field" and the fact that it's not editable via

                                the Properties window. I know of no other way to change the name of the

                                field. Since this is a work product, I cannot send it to you. I'll try

                                to figure something else out.

                                 

                                 

                                 

                                Thank you.

                                 

                                 

                                 

                                Tonya Chartrand CAP-OM

                                 

                                 

                                 

                                Edward Rose & Sons

                                 

                                Administrative Assistant

                                 

                                Training Department

                                 

                                (269) 321-7886 fax (269) 321-7884

                                • 13. Re: Adobe Pro X and JavaScript
                                  try67 MVP & Adobe Community Professional

                                  Sorry, but I don't know of a more simple way of explaining it than "it's

                                  the text you enter into the field itself"... Not the name of the field, or

                                  any other property of it. Just the value you type into it.