22 Replies Latest reply on Aug 14, 2014 1:20 PM by gkaiseril

    Function Expressions not working in Acrobat

    xavierharrell

      I have a form that has addition, subtraction and multiplication. Here is my script at the document level. When I place the custom calculation script on the total fields I get this error. Any ideas why I get this error?

       

       

      TypeError: calculate is not a function

      1:AcroForm:total.0:Calculate

      TypeError: calculate is not a function

      1:AcroForm:total.1:Calculate

       

      **************Script*******************

      var calculate = function(){

          var fn = Array.prototype.pop.apply(arguments);

          return fn.apply(null, arguments);

      };

      var multiply = function() {

           var total = 1;

           for (var i = 0; i < arguments.length; i++){

             total = total * arguments[i];

           }

        return total;

      };

      var add = function(){

          var total = 0;

          for (var i = 0; i < arguments.length; i++) {

              total = total + arguments[i];

          }

          return total;

      };

      var diff = function (){

          var total = Array.prototype.shift.apply(arguments);

          for (var i = 0; i < arguments.length; i++) {

              total = total - arguments[i];

          }

          return total;

      };

       

      ***********Custom Calculation Script***************

      var testTotal = calculate("field1".value, "field2".value, multiply);

      event.value = testTotal;