7 Replies Latest reply on Jul 7, 2015 6:36 AM by greyson653

    A little help please...


      I have a 26 page form that I am creating for work.  I need a custom script that will allow me to do this:


      I have a column (AW) that has multiple (25) rows/fields (i.e., AWRow1, AWRow2, etc.) per page (for 25 pages).


      Within each of these fields, users are going to put 1 P, 1 B, or leave it blank.


      I would like to create a script that will allow me to calculate the 1 P’s and 1 B’s to their own dedicated total fields on a summary page (i.e., distinguishing and correctly calculating the 1 P’s and 1 B’s appropriately)


      Any help would be highly appreciated, and hopefully, I have been descriptive enough to where someone can help me.  If not, please just ask, and I will attempt to provide more clarity.


      Thanks in advance

        • 1. Re: A little help please...
          George_Johnson MVP & Adobe Community Professional

          Are you using text fields or dropdowns for this? If text fields, why did you decide to use them instead of dropdowns?

          Are your fields named "AWRow1" through "AWRow625"?

          • 2. Re: A little help please...
            greyson653 Level 1

            I initially created the document in Word, and then converted it to a .pdf.  I then created it into a form, and I allowed it to automatically designate the fields.  Unless there is a way to change a field type (i.e., from a text field to dropdown), other than deleting the existing text field, and replacing it with a dropdown field; I just didn't think it was worth doing that 625 times.  Also, the last field for AW #625 is AWRow25_25, which was also assigned when I converted it to a form.


            Basically, I just need an idea of how to get started, and I think I can do the rest.


            Thanks for the response , any more help would be highly appreciated.

            • 3. Re: A little help please...
              George_Johnson MVP & Adobe Community Professional

              Unfortunately, Acrobat doesn't provide a means to change one type of field to another, or an easy way to change the field names of a lot of fields.


              What you need to do is create a custom calculation JavaScript for one of the summary fields on the last page. It would loop through the fields and look at the value of each, and keep a running total of each. It would then set the value of each summary field to the corresponding total. The problem you're going to have with the form set up this way is people are going to make mistakes entering the values (e.g., users might enter "1  p" instead if "1 P") and your current field names will not make it easy to loop through them.


              You can alter the field values to correct for certain common errors, by converting to upper case and removing any leading/trailing white space, or converting "1P" to "1 P", but this will make the script more complicated.


              I'm not going to suggest any code for how the form is currently set up. If you were to recreate the form with dropdowns using a convenient field naming scheme, this would be simple, but I realize that can be a lot of work without any automation tools like I'd use in a case like this.

              • 4. Re: A little help please...
                greyson653 Level 1

                Thanks so much for your response .  One of the other problems is, I have four other columns that I would like to do this with, so I technically would have to do it over 3,000 times, not just 625 .  However, if I were to go this route, I would create one "page" with dropdown fields, and then copy/paste it 24 times.  With that, I would then have to go through and provide each dropdown field its own unique identifier, which you are suggesting anyway (i.e., having a more convenient naming scheme).


                I think in the long run, this is the best route to go, even though it means I have a lot more work to do.  Given that, would you be willing to help me out on the JavaScript end since this is what I plan on doing now?


                Again, thanks so much  

                • 5. Re: A little help please...
                  greyson653 Level 1

                  So, I made the suggested changes to the form setup.  I have attempted to find a Javascript that applies to what I am attempting to accomplish, but everything I have plugged in has yet to work.


                  Here is another quick overview of what I am trying to accomplish:  I have a column with dropdown fields named (AWRow1, AWRow2, etc.).  The dropdown options are P or B.  I have a summary page that has two total fields designated for how many P's or B's have been selected.


                  Any help on the Javascript end would be highly appreciated.

                  • 6. Re: A little help please...
                    George_Johnson MVP & Adobe Community Professional

                    I'm not sure what all of the field names are, but I'll assume AWRow1 through AWRow625, and the the total field names are Total_P and Total_B. The custom calculation script for the Total_P field could be:


                    // Custom calculation script for "Total_P" field. Change the field names to match your form

                    (function () {


                        // Initialize some variables

                        var sum_P = 0;

                        var sum_B = 0;

                        var i, v, fn_prefix = "AWRow";


                        // Loop through the fields and count the number of P and B selections

                        for (i = 1; i < 626; i += 1) {

                            v = getField(fn_prefix + i).value;

                            switch (v) {

                            case "P": sum_P += 1; break;

                            case "B": sum_B += 1; break;




                        // Set this field's value

                        event.value = sum_P;


                        // Set the other field value

                        getField("Total_B").value = sum_B;





                    I haven't tested this, so there may be some problems, but it should get you started.

                    • 7. Re: A little help please...
                      greyson653 Level 1

                      Thank you for your help, George.  The Javascript was missing a variable, but I just deleted a comma and I was able to close the custom Javascript popup box.  It's working!  Again, thank you so much for the help.  Hopefully, I can do the rest myself.  If not, you may get another reply from me on this thread, hah.  Again, thank you so much for the help, sir.