Quantcast
Channel: Adobe Community : Popular Discussions - JavaScript
Viewing all articles
Browse latest Browse all 12130

Function Expressions not working in Acrobat

$
0
0

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;


Viewing all articles
Browse latest Browse all 12130

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>