6 Replies Latest reply on Sep 22, 2012 11:09 PM by George_Johnson

    Multiple Dependent Dropdowns in Acrobat

    Siwar3

      Hello,

       

      I'm a first time poster but I've found valuable information here in the past so I'm hoping someone can help me with a PDF form I'm creating.

       

      I am looking to have a selection from a dropdown list (Departments) populate 4 other dropdown lists (software available for selected department).

       

      For example: In Box1 the user selects "Graphic Design" and Box2, Box 3, Box4, and Box5 are all populated with the exact same options (Photoshop, Illustrator, InDesign, etc)

       

      Currently, I can populate Box1 and depending on what is selected Box 2 populates correctly.  However, I can't seem to get the other boxes to populate. I've been using the scripts referenced here and I will paste it below.

       

      Any help would be greatly appreciated.

       

      Thanks.

       

       

       

       

      Ex:

      Let's say you have two combo boxes - box1 and box2.

      And let's give box1 3 chooses: Blank, a and b.

      If user chooses option a, box2 will contain choices C and D.

      If user chooses option a, box2 will contain choices E and F.

      Remember to check the "Commit selected value immediately" for the boxes.

       

      In box1 you use the keystroke script from the article and modify it:

       

      if( event.willCommit )

      {

      if(event.value == "")

      //if nothing is chosen in box1 then box2 will be cleared

      this.getField("box2").clearItems();

      else

      SetFieldValues(event.value);

      }

       

      Then you have to modify the document script from the article a little bit.

       

      //First you make the values for box1.

      myBox1Values = ["", "a", "b"];


      //Then you populate the values to box1.

      this.getField("box1").setItems(myBox1Values);



      // Then you define what has to be shown in box2 when value is selected

      var DeptData = { a: ["C","D"],

      b: ["E","F"]

      };


      //Finally you set the values of box2

      function SetFieldValues(cDeptName)

      {

      this.getField("box2").setItems(DeptData[cDeptName]);

      }

        • 1. Re: Multiple Dependent Dropdowns in Acrobat
          George_Johnson MVP & Adobe Community Professional

          You could just change the function at the end to:

           

          function SetFieldValues(cDeptName) {

              getField("box2").setItems(DeptData[cDeptName]);

              getField("box3").setItems(DeptData[cDeptName]);

              getField("box4").setItems(DeptData[cDeptName]);

              getField("box5").setItems(DeptData[cDeptName]);

          }

          • 2. Re: Multiple Dependent Dropdowns in Acrobat
            Siwar3 Level 1

            George,

             

            Thank you very much for your response.  I tried to implement your suggestion but I continue to receive the Windows "critical stop" sound when I click on the drop down arrow for "box3" and beyond, and nothing is populated.  I'm sure, being a complete novice, that something fairly simple is eluding me but I can't seem to find it.

             

            If you or anyone else can offer any more suggestions it would be most appreciated.

             

            *Edited for spelling

            • 3. Re: Multiple Dependent Dropdowns in Acrobat
              George_Johnson MVP & Adobe Community Professional

              Look to see if any errors are reported in the JavaScript console (Ctrl+J). If so, post again with the exact text. If there's nothing, can you poast a sample somewhere?

              • 4. Re: Multiple Dependent Dropdowns in Acrobat
                Siwar3 Level 1

                Thanks again George for your response.

                 

                The JavaScript console reports the following (Department Software 2 = Box3 in my OP):

                 

                Acrobat EScript Built-in Functions Version 9.0
                Acrobat Annotations / Collaboration Built-in Functions Version 9.0
                Acrobat Annotations / Collaboration Built-in Wizard Functions Version 9.0
                Acrobat SOAP 9.0

                TypeError: getField("Department Software 2") is null
                66:Field:Keystroke
                TypeError: getField("Department Software 2") is null
                65:Field:Keystroke
                TypeError: getField("Department Software 2") is null
                65:Field:Keystroke
                SyntaxError: syntax error
                14:
                SyntaxError: syntax error
                14:
                SyntaxError: syntax error
                14:
                SyntaxError: syntax error
                14:

                • 5. Re: Multiple Dependent Dropdowns in Acrobat
                  George_Johnson MVP & Adobe Community Professional

                  > TypeError: getField("Department Software 2") is null

                   

                  What this means is that there is no field with that name. It has to match exactly.

                   

                  The syntax error is more difficult since I can't see the exact script you're using. If you can't post a sample, I'd be happy to take a look if you're free to email it to me: acroscript at gmail dot com

                  • 6. Re: Multiple Dependent Dropdowns in Acrobat
                    Siwar3 Level 1

                    /facepalm.....

                     

                    As I suspected it was something simple right in front of my face. The field name was "Department Software2" and the script was written as "Department System 2"

                     

                    George, thank you so much for helping me with this!