1 Reply Latest reply on Nov 7, 2014 10:56 AM by SEJohnson3

    Automatically numbering fields

    SEJohnson3

      I am creating a PDF form in Adobe Acrobat 9 that has a rows of fields that each represent a line in a database. The user will fill out a line for each individual specimen.  To make the form I create the first row then use the "place multiple fields" function to repeat this for the number of rows I need.  This way the fields have a predictable naming scheme and the data can be easily extracted when the data entry is complete. I know that PDF forms do not really work on the concept of rows. The data will be extracted into rows based on the field naming convention. The first field in each row is a row number. What I am trying to do is to use Javascript to automatically fill the line number fields.  How I envision this working is that the user will type a number into a field somewhere on the form to indicate the first row number they want. Once they move away from that field I want the row number fields to be populated with row numbers starting with the number the user typed in and incrementing  by one for each row.  I have tried a few things but the latest is:

       

      As an on blur action in the properties of the "begin row number" field:

       

      lnenbr = 0;

      lnenbr = getField("First Line Number").value;

       

      As a custom calculation script for each of the "row number fields" ( Named LineNum_1.0 with the portion after the "." incrementing by one for each row):

       

      var f = this.getField(event.target.name) //creates a variable for the row number form field

      f.value = lnenbr //sets the form field to equal the counter

      lnenbr ++ //increments the the counter by one

       

      This works, but not correctly.  If I type a number in the "begin row number" the mouse click off that field nothing changes in the row number fields.  If I then type a new number in the "Begin row number" field, then mouse click off of that field, the row number fields are numbered in sequence but beginning with the previous value I typed in "begin row number".  Also the first row number field does not change.  Any ideas on how I could get the behavior I want either through a modification of my method or something completely different?  I am a Javascript novice.

        • 1. Re: Automatically numbering fields
          SEJohnson3 Level 1

          I answered my own question. I will put the answer here in case anyone has a similar problem.  As an on blur action in the"begin row number" box I put this Javascript:

               this.calculateNow();

          So that the line number fields will recalculate after I enter the begin line number.  In the calculate property for the "begin row number" I put:

               lnenbr = 0;

               lnenbr = this.getField("First Line Number").value;

          To set the value of the line count variable to 0 and load the beginning line number into a variable.  In the first "row number" text box I put this calculate script:

               event.value = lnenbr//sets the value of this line number box to the lnenbr variable.

               lnenbr ++ //increments the the counter by one

          Then I did the "place multiple copies" process on the row numbers text box. This worked but except when I entered the beginning line number the first line number changed to what should have been the last line number.  That turned out to be a function of the calculate order of the fields.  I changed that under "forms/edit fields/change field calculation order" when in form edit mode.  Now the whole thing works as I had planned.