1 Reply Latest reply on Jan 21, 2012 11:39 AM by George_Johnson

    Stuck on and array, trying to isolate a field




      I'm VERY new to JavaScript and am totally stuck. I'm building an editable order form in Adobe Acrobat and I'm trying to get Acrobat to add an array of fields together, isolating the last field that has to be multiplied by 8 in order to get a proper unit count. The last field is a multi-pack, so has to be mulitplied by 8. I've built all of the fields and they're numbered from .01 to .12, but Acrobat keeps changing the field that's being multiplied by 8 to the first (.01) field. There are about 50 different products in this form and I can't seem to get the formula I was given to work properly. Here's what I've been working with:



          var oField = this.getField('aerial');

          var p = 26;

          var n = 8


          aField = oField.getArray();

          var gSum = aField.shift().value;

          var fSum = 0; // variable for sum of individual qtys

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

              fSum += Number(aField[i].value); // add values



          event.value = (fSum * p) + (gSum * (p*n));


      I don't know anything about coding and I've been stuck on this for hours and just can't seem to get it right. Any help would be appreciated.