2 Replies Latest reply on Sep 14, 2010 4:59 PM by George_Johnson

    How do you calculate multiple fields in a Form?

    DCFourie

      Hi,

       

      I have a spreadsheet with several headings and several fields as illustrated below, and description of each field and calculation required is listed below.

       

       

      Rate Per DayDaysCourseAttendingTotal
      $1,0002Course AYes$2,000
      $2,0001Course BYes$2,000
      $5,0005Course CNo-
      $2,0002Course DYes$4,000
      Total:$8,000

       


      Rate per day:  Field value is inputted by us.

       

      Days:  Field value is inputted by us.

       

      Course:  Field value is inputted by us.

       

      Attending:  Is actually a check-box that the client ticks.

       

      Course Total:  This should be the calculation of RATE PER DAY * DAYS IF ATTENDING BOX IS CHECKED

       

      Total:  Sum of above COURSE TOTAL FIELDS

       

      We currently do this in EXCEL 2007, however we looking at converting it to a PDF Form for distribution to our clients to we can track responses, etc.

       

      My question is really ery simple ... how do I create the above calculations in a form that I want to distribute??  This possible?? If so how (please bear in mind I'm not a developer

        • 1. Re: How do you calculate multiple fields in a Form?
          George_Johnson MVP & Adobe Community Professional

          Sure it's possible. The are three ways to set up a calculated field:

           

          1. Use the built in routines of: Value is the [sum|product|average|minimum|maximum] of the following fields {you pick the fields}

          2. Use "simplified field notation"

          3. Create a custom calculation script

           

          The first two have some limitations, but may suit your needs. For anything more complicated, you usually need to create a custom calculation script.

           

          You can see these three option on the Calculation tab of the Text Field Properties dialog. More information about the first two are in Acrobat's help and there are tutorials at acrobatusers.com.

           

          Also, remember to set calculated fields to read-only, as you normall do not want the user to be able to attempt to interact with such fields.

          • 2. Re: How do you calculate multiple fields in a Form?
            George_Johnson MVP & Adobe Community Professional

            In re-reading your question, I realized you're using a check box. In that case, you will need to create a custom calculation script using JavaScript.

             

            Something like:

             

            // This is a custom calculation script

            (function () {

             

                // Get the value of the check box

                var v1 = getField("Attending1").value;

             

                if (v1 !== "Off") {

                    var v2 = +getField("Rate1").value;

                    var v3 = +getField("Days1").value;

             

                    // Sum the two field values and set the value of this field to the result

                    event.value = v2 + v3;

                } else {

             

                    // Blank field if checkbox is unchecked

                    event.value = "";

                }

             

            })();

             

            You'd replace the field names I used with the field names you're using.

             

            This leaves out checking to see if the corresponding Couse field is filled-in, and you'll have to use a custom Format script if you want the type of formatting you show.