8 Replies Latest reply on Mar 10, 2015 5:25 AM by defkopta116

    Javascript to divide unevenly

    defkopta116

      Hey guys,

       

      So I've been working on a form in Adobe Acrobat Pro XI, and I have come up with some things I need to do with Javascript - but I can't quite work out how to do it. Any help would be greatly appreciated!

       

      The slighly curly problem is that I have a box which has a main total, and I then divide that total into three new boxes. Simple enough except that in the case of a number that doesn't evenly divide by 3, I don't want fractions. I want it to divide unevenly, and for it to put the larger number in, say, box 3, then 2 if there's still another one.

       

      I'll give you an example: If the Total box is 28, then I would want the other boxes to be: box 1:8 box 2:8 box 3:9

       

      If the Total box is 29, then I would want the three derivative boxes to be: box 1: 8, box 2: 9, box 3: 9

       

      Hope that makes sense!

       

      The formula I have currently been using is: event.value = ( this.getField("Total Health").value/ 3)

       

      This divides the Total box into thirds, and gives a fraction (so in the case of 28, it gives 9.33333333...)

       

      Cheers!