1 Reply Latest reply on Aug 16, 2015 9:44 AM by gkaiseril

    Need help with rounding...




      I am working on a fillable form in Acrobat XI.  I have been able to figure out how to make some fields auto-calculate using simplified field notation.  However, I do not have much experience with this or javascript.


      What I need is for a field to round up to the next 0.25 when doing its calculation.  Currently, I have simplified field notation taking a field that shows the sum of two fields and dividing by 60.


      totalpca / 60


      A response to this equation may be something like 15.55.  However, what I need it to read is 15.75.  (Because it rounded up to the next 0.25)  My numbers should all end in .00, .25, .50, or .75, with it always rounding up.  I am pretty sure, if this is possible, it would need to be done with javascript, but I don't even know where to begin.


      Thank you for any help you can offer!

        • 1. Re: Need help with rounding...
          gkaiseril MVP & Adobe Community Professional

          Do you know how to do this with paper an pencil?

          1. Compute the number of  whole 25 units in the value.

          2. Change the value to the next larger integer.

          3. Convert the number of 25 units back to a decimal number.

          // field names as variables for processing;
          var cField1 = "Text1";
          var cField2 = "Text2";
          // vlaue for decimal adjusment;
          var nDecAdj = 100
          // value for unit to adjust to;
          var nUintAdj = 25
          // clear the result;
          event.value = "";
          // get the values of the fields;
          var oField1 = GetField(cField1);
          var oField2 = GetField(cField2);
          // sum the numeric values of the field;
          var nSum = Number(oField1.value) + Number(oField2.value);
          event.value = Math.ceil(nSum * (nDecAdj / nUintAdj)) * (nUintAdj / nDecAdj)