3 Replies Latest reply on Jul 22, 2016 12:02 PM by gkaiseril

    Javascript for calculation of weighted grades

    WestbrookSchools

      I am working on a form that has calculated 6 seperate domains.  Each domain has a percentage weight that I need to calculate.  It works for me in excel but don't know how to do a javascript for pdf.

        

      GradeWeightScore
      9110%7.35
      6515%11.025
      8020%14.7
      7325%18.375
      6830%22.05
      377
      75.473.5
      AverageWeighted

      Here is my formula for the 73.5 weighted calculation=SUMPRODUCT(A3:A7, B3:B7)/SUM(B3:B7)

      I tried this script but it doesn't work

      =SUMPRODUCT(Rating_Domain_1+Rating_Domain_2+Rating_Domain_3+Rating_Domain_4+Rating_Domain_ 5+Rating_Domain_6, Score_1+Score_2+Score_3+Score_4+Score_5+Score_6)/SUM((Score_1+Score_2+Score_3+Score_4+Sco re_5+Score_6)

      Where Rating Domain = Grade and Weight = Score

      Any help is appreciated.

        • 1. Re: Javascript for calculation of weighted grades
          gkaiseril MVP & Adobe Community Professional

          Exactly where did you place this script?

           

          It does not meet the coding requirements for using the Simplified Field Notation and does not use the statements needed by the custom JsvaScript option.

           

          Have opened the Acrobat JavaScript console to see any syntax errors or other run time issues?

          • 2. Re: Javascript for calculation of weighted grades
            WestbrookSchools Level 1

            I tried both Simplified Field Notation and Custom but obviously I don't do javascript and hoping that someone could take my excel formula and create the javascript

            • 3. Re: Javascript for calculation of weighted grades
              gkaiseril MVP & Adobe Community Professional

              Excel formulas are not JavaScript. Also Acrobat forms use field names and column and row ranges.

               

              Many of the Excel functions do not exist in JavaScript so you either have to create a custom function or write the code to perform the function.

               

              Adobe provides for free the Acrobat JS API Reference and other documentation about Acrobat JavaScript in the.be Acrobat Developer Connection at Adobe.com. The Mozilla Developer Network provides for free the JavaScript Reference. There are also numerous tutorials available through links on this site.

               

              If you were to look at the calculation options and how they work, you would see it is possible to compute all the values you need using the "Field is the ______ of the following fields:". You can sum, multiply, and average which should be all of the operations you need.