5 Replies Latest reply on Sep 22, 2010 3:48 PM by George_Johnson

    Using Data From Multiple Fields to Auto Fill a Portion of Other Fields

    davpow

      Hello, I'm somewhat new to acrobat and need some help. I'm looking for a way to take data from 2 fields, and have it auto fill into a 3rd field. Then be able to add to the 3rd field. For example, taking 3 letters (ABC) from field 1, then 2 number (12) from field 2, and having them auto fill in field 3 (ABC12), then be able to edit that (ABC1201.jpg) and not have it effect fields 1 and 2.

       

      Any help would be great.

        • 1. Re: Using Data From Multiple Fields to Auto Fill a Portion of Other Fields
          George_Johnson MVP & Adobe Community Professional

          In response to what action do you want the third field to be filled with the values of the first two fields? You could do it in response to each of the first two field values being committed, the push of a button, or something else. The specific code you'd use would be different depending on how you want it to work.

          • 2. Re: Using Data From Multiple Fields to Auto Fill a Portion of Other Fields
            davpow Level 1

            I'd like the 3rd field (it's actually several fields) to auto fill as the first 2 are filled. So I guess it's the values being committed. If this makes it easier, here is a bit more information on what I'm trying to figure out.

             

            We have our clients filling out PDF forms to submit ad information. They are assigned a 3 letter acronym in our database that is specific to them (which is the ABC) and then we have the  issue number (the 12) which need to be included with every image they submit. We are looking for a way to have the form auto fill out the 3 letter acronym and issue number in all the image fields so they can just type in 01.jpg, 02.jpg and so on. It seems like a small thing to have them fill out the extra 5 characters on their own, but clients get lazy extremely fast when it comes to things like that.

            • 3. Re: Using Data From Multiple Fields to Auto Fill a Portion of Other Fields
              try67 MVP & Adobe Community Professional

              If all you need is to add ".jpg" at the end, then there's no need to

              manually edit the field, which just makes the entire thing more complicated.

              If that's the case, you can use something like this as the 3rd field's

              custom calculation script:

               

              event.value = this.getField("Field1").value + this.getField("Field2").value

              + ".jpg";

              • 4. Re: Using Data From Multiple Fields to Auto Fill a Portion of Other Fields
                davpow Level 1

                That might come in handy to throw in as well, but they need to ad the image number. They can have up to 80 new images every week. So they need to add the image number and the .jpg. The actual image name in our database ends up being ABC1201.jpg.

                • 5. Re: Using Data From Multiple Fields to Auto Fill a Portion of Other Fields
                  George_Johnson MVP & Adobe Community Professional

                  Here's a function you can call in each of the first two field's custom Validation scripts. It is intended to be placed as a document-level function (Advanced > Document Processing > Document JavaScripts...).

                   

                  function set_v3() {

                   

                      var fn1 = "t1";  // name of first field
                      var fn2 = "t2";  // name of second field
                      var v1, v2;

                   

                      // Get the values of the first two fields
                      // depending on which field triggered this function
                      switch (event.target.name) {
                      case fn1 :
                          v1 = event.value;
                          v2 = getField(fn2).valueAsString;
                          break;
                      case fn2 :
                          v1 = getField(fn1).valueAsString;
                          v2 = event.value;
                          break;
                      }

                   

                      // Set the third field value to v1 + v2
                      getField("t3").value = v1 + v2;
                  }

                   

                  Replace the field names "t1", "t2", and "t3" above with the actual names of the fields you're using. Here's what the Validate script for the first two fields should be:

                   

                  // Custom Validate script for the first two fields

                  set_v3();

                   

                  You can name the function whatever you like.