1 Reply Latest reply on Jul 14, 2010 9:21 AM by gkaiseril

    Field Rounding

    toby.williams247 Level 1

      I am trying to round a field to a whole number, avoiding decimal places> While Acrobat's formatting seemingly allows this to happen, when exporting the data captured on a form the whole value is given i.e. 1000 is exported as 1000.1677777.

       

      I am already using a calculation to obtain the value, being

       

      if( this.getField("GSTV").value > 0)
              event.value = this.getField("GSTV").value / this.getField("GSAN").value
      else
      event.value = "";

       

      Does anyone know of a format string or calculation string I can include to achieve the desired result.

       

      Thank you in advance

        • 1. Re: Field Rounding
          gkaiseril MVP & Adobe Community Professional

          Formatting rounds a field's actual value. JavaScript has a number of 'rounding' type methods as part of the 'Math' object or one can use the 'util.printf' method to create a rounded numeric string for the field. I would use a funciton to perform the rounding, so one could resuse the code in other fields in the form or in other forms.

           

          function Round(nValue, iDecimals)
          {
          /*
          Purpose: round a nmber to a given number of decimal places
          Inputs:
          nValue -  number to be rounded
          iDecimals - number of decimal palces for the rounded results
          Returns: the round value of the nValue
          */
          return util.printf("%,0 0." + iDecimals + "f", nValue)
          }