5 Replies Latest reply on Nov 19, 2013 9:08 AM by HTCTruck

    Auto Populating Field

    HTCTruck

      Hello there, I'm seeking direction here on a form I'm building.  I'm using Acrobat XI and what I'm shooting for is I'd like the Year Field on the left under Vehicle Information to auto populate depending on the value of the 10th digit in the VIN number.  For example, below I have "0" in the 10th spot, which is the year 2000, so I'd like the Year field to adjust to reflect 2000.

       

      I'm a web designer, so I do have some JS experience.  Would this be using if/then statements?  Any help/direction is appreciated, thanks!

       

      vin.png

        • 1. Re: Auto Populating Field
          try67 MVP & Adobe Community Professional

          Are you sure that this is determined by a single digit? Is "9" 2009? Can't it be 1999? What about "2"? Is it 1992? 2002? 2012?

          • 2. Re: Auto Populating Field
            HTCTruck Level 1

            I used these as an example, the full list is below:

             

            P=1993

            R=1994

            S=1995

            T=1996

            V=1997

            W=1998

            X=1999

            Y=2000

            1=2001

            2=2002

            3=2003

            4=2004

            5=2005

            6=2006

            7=2007

            8=2008

            9=2009

            A=2010

            B=2011

            C=2012

            D=2013

            E=2014

            • 3. Re: Auto Populating Field
              try67 MVP & Adobe Community Professional

              Ah, OK, that makes more sense. So it's not a digit, but a character.

              In that case you can use a series of if-else commands, or a switch command.

              The former would look something like this:

               

              var v = this.getField("Vin-10").valueAsString;

              if (v=="P") event.value = "1993";

              else if (v=="R") event.value = "1994";

              else if (v=="S") event.value = "1995"; //etc.

              else event.value = "";

               

              Adjust the name of the field in the first row, and place the code as the custom calculation script of the Year field.

              • 4. Re: Auto Populating Field
                gkaiseril MVP & Adobe Community Professional

                Getting the year of production for an automobile might be a little more complex then looking at the 10 position. Since the coding for a single digit omitting the possible confusing letters or I, O, Q, and Z only allows a span of 29 years or 1980 through 2009. The 10 digit does repeat for the next 29 years using the same single digit code so A could be 1980 or 2010. One needs to the 7th character for vehicles with GWR 0f 10,000 or less.

                 

                The JavaScript substr or substring methods will work with Acrobat JavaScript assuming you are using single field for the VIN.

                • 5. Re: Auto Populating Field
                  HTCTruck Level 1

                  That's perfect.  Exactly the direction I needed.  Thanks!