4 Replies Latest reply on Mar 6, 2013 8:07 PM by 8mittens

    Acrobat X Pro, Drop Down with Lots of options+filling 2 other fields

    8mittens

      I have 3 columns of particular interest. The current form uses 2 drop down boxes, and one manual text box.

      I'm interested in refining the process. I'd like to pick the one most significant data from the first drop down list and it would then fill the 2 other boxes with appropriate, predetermined data.

       

      I did find http://acrobatusers.com/tutorials/change_another_field which has lead to much testing, & I keep failing.

      I copy the JS into Word twice, then attempt to replace keywords with the box titles and other variables I'm using.

       

      What is the correct way to list Lots of items from the drop down box? It's item numbers. ###-### format. Is that a problem?  (I think it is) What suggestions might you have for a work around? (custom number format the item column of boxes?)

      Oh, that other part from the guide is in there too (within properties, custom format for item boxes):

       

      //<AcroForm>

      //<ACRO_source>Item0:Keystroke</ACRO_source>

      //<ACRO_script>

      /*********** belongs to: AcroForm:Item0:Keystroke ***********/

      if( event.willCommit )

      {

         if(event.value == " ")

           this.resetForm(["Description.0","Price.0"]);

         else

           SetFieldValues(event.value);

      }

      //</ACRO_script>

      //</AcroForm>

       

      Next fun part is matching the few descriptions with the Lots of Item Numbers. Reusing descriptions across a list of item numbers.

      The last fun column of boxes is price. Again few prices across Lots of item numbers.

       

      Meanwhile, BIG Thanks to Thom Parker and I've been using the guide I linked above:

      Open Form. Edit. JS. Document JS: SetFieldValues

       

      // Place all prepopulation data into a single data structure

      var DeptData = { Accounting:{ contact: "Steala Damuni",

      email: "accounting@mycomp.com",

      deptnum: "cmp1234" },

                       Engineering:{ contact: "Frank N. Stien",

      email: "engineering@mycomp.com",

      deptnum: "eng1234" },

      Marketing :{ contact: "Shelly Oughtbuks",

      email: "marketing@mycomp.com",

      deptnum: "mkt1234" },

      ITSupport:{ contact: "Goah Wei",

      email: "it@mycomp.com",

      deptnum: "its1234" }};

      function SetFieldValues(cDeptName)

      {

      this.getField("DeptContact").value = DeptData[cDeptName].contact;

      this.getField("DeptEmail").value = DeptData[cDeptName].email;

      this.getField("DeptNumber").value = DeptData[cDeptName].deptnum;

      }

       

       

      and here is one of my scary reimaginings:

      SetFieldValues

       

      //Put it all in here

      var ItemData = { 321-321, 321-432:{ Description0: "hard",

      Price0: "61.25" },

      123-123, 123-234:{ Description: "soft",

                                    Price: "95" }};

      function SetFieldValues(cItem0)

      {

      this.getField("Description0").value = ItemData[cItem0].Description0;

      this.getField("Price0").value = ItemData[cItem0].Price0;

      }

       

      gets me syntax error. I take out the - in the item number it seems to move beyond, but then app crashes. /shrug. I'm very curious about the proper method to list Lots of item numbers in a SetFieldValues situation??

       

      I've got 10 rows in the columns and figured each row is going to need it's own setfieldvalues pertaining to the name of the cells in the row. From top down, Item0, Item1, Item2, etc. (Description0 & Price0 too). Thank you!

        • 1. Re: Acrobat X Pro, Drop Down with Lots of options+filling 2 other fields
          gkaiseril MVP & Adobe Community Professional

          You write JavaSript in plan text. Use Acrobst's built-in editor or a plain text editor not a word processor since the use special hidden codes for formatting that cannot be processed by compilers or interpreters.

          1 person found this helpful
          • 2. Re: Acrobat X Pro, Drop Down with Lots of options+filling 2 other fields
            8mittens Level 1

            THANKS. good to know. Let me get it straight. If I work out the rough edges of the script in Word, and then try to copy and paste from Word into the Acrobat JS window it will fail because of the copy and paste from Word?

            If I copy and past from Word into Stickies (Mac app) or TextEdit, and then copy that and paste into Acrobat JS window, will it also fail? Better to just have 2 windows open and type each attempt into JS window after using an alt app for zoom feature and easier typing due to being able to see the text more clearly (zoom in)?

            • 3. Re: Acrobat X Pro, Drop Down with Lots of options+filling 2 other fields
              gkaiseril MVP & Adobe Community Professional

              From your testing Word does not work!

               

              MS Word is a word processor and uses special codes that are not within the ASCII character set of 128 codes. No matter where you cut and paste Word content the special characters will be pasted into that program.

               

              You cannot use a saved Word Doc. You cannot cut and paste form Word to another word processor and then cut and paste into JavaScript.

               

              You can only use the 129 characters of the basic ASCII character set and no other codes. A text editor will use these codes and is designed for editing program text.

               

              Why are you not using Acrobat's built-in JavaScript editor?

               

              You can associate a 3rd party text editor with Acrobat so there is no need for cutting and pasting.

               

              Have you looked and the instructions for editing JavaScript in Acrobat?

               

              Also so do not edit in the "Edit All JavaScripts" window with any type of editor!

               

              The warning is serious and truthful.

              • 4. Re: Acrobat X Pro, Drop Down with Lots of options+filling 2 other fields
                8mittens Level 1

                seriously thank you.

                Meanwhile, there were questions above that.

                The ittybitty text is driving me nuts. Changed resolution. Helps.

                 

                Using that guide JS in 1st post, the "function SetFieldValues(cDeptName)" I can't seem to find another mention of DeptName other than the lines below it. It is Not a PDF box name. It's a thorn in my understanding of the guide. Why the cDeptName? Anything goes? Could have used function SetFieldValues(cSludge)? Then what does it point to or associate with? Is it some sort of 4 letters of a word are good enough?

                 

                Then the next part of my confusion is trying to use the guide in a per row situation.

                I've seen this "var cRowName = event.target.name.split(".").shift();" in a few other examples. All tries to add it or some variation of it with other lines to my situation = error. Super fun after adding 100 Part numbers and have to start over each time I try something different. I have a few saved PDFs with variations of JS in it that didn't end in error. Here is a shortened example of something

                 

                var Parts = {

                        "020-001": { Description: "Soft", Price: 61.25},

                        "022-000": { Description: "Chewy", Price: 52},

                };

                 

                function setFieldValues(cJabawonkie)

                {

                this.getField(cRowName + "Description").value = Parts[cParticulars].Description;

                this.getField(cRowName + "Price").value = Parts[cParticulars].Price;

                }

                 

                Is there a limit to this type of list, I reached a syntax error near the bottom, removed last 3 lines of Part Numbers and was able to close and save. Examining the lines I had to remove, they look no different from lines above them (only difference was part number).

                 

                I'm trying to use a master list  that contains Part Number, specific Description, and specific Price. Select a Part Number from the DropDown lost, and the Description and Price are displayed.

                If row1.PartSelection = 020-001, then row1.Description = Soft & row1.Price = 61.25

                 

                thank you, from a noob

                 

                I'm depressed that I can't add/replace the Part numbers that i had to delete earlier on, at the bottom of the list without getting: "SyntaxError: missing : after property id"

                and this is copy and paste the last Part number or any other Part number line to the bottom of the list and changing one digit of the part number. Why is every line before fine and this one at the bottom not fine?

                ...plan B? hmmmm. suggestions?