8 Replies Latest reply on Dec 14, 2016 12:49 AM by PYZ

    Image with Drop down in Adobe Acrobat X pro

    PYZ

      Greetings all,

       

      I am new to the JavaScript Adobe Acrobat Form and trying to create a form here with the images and a drop down box.

       

      I use button command to place an image in it where I would like to have my image to appear when one of the option from the drop down box is selected:

       

      When Option 1 is selected, image 1 (button) will be visible, image 2 & 3 are invisible

      When Option 2 is selected, image 2 (button) will be visible, image 1 & 3 are invisible

      When Option 3 is selected, image 3 (button) will be visible, image 1 & 2 are invisible

      Otherwise all the images will be invisible

       

      How do I start or write a full JavaScript with the above condition as mention?

       

      Thank You.

        • 1. Re: Image with Drop down in Adobe Acrobat X pro
          George_Johnson MVP & Adobe Community Professional

          The custom validation script of the dropdown could be:

           

          (function () {

           

              // Get references to the image buttons

              var f1 = getField("image1");

              var f2 = getField("image2");

              var f3 = getField("image3");

           

              // Hide all of the images

              f1.display = display.hidden;

              f2.display = display.hidden;

              f3.display = display.hidden;

           

              // Show an image based on the selection

              switch (event.value) {

              case "Option 1" :

                  f1.display = display.visible;

                  break;

              case "Option 2" :

                  f2.display = display.visible;

                  break;

              case "Option 3" :

                  f2.display = display.visible;

                  break;

              }

           

          })();

           

          You may need to change the field names or the dropdown values I assumed, but it should get you started.

          • 2. Re: Image with Drop down in Adobe Acrobat X pro
            PYZ Level 1

            Hi George,

             

            I use your script, change field names and dropdown values but the the image didn't become visible when I select the option.

            All the images are hidden and it doesn't show any errors for the script.

             

            Please advise.

            • 3. Re: Image with Drop down in Adobe Acrobat X pro
              try67 MVP & Adobe Community Professional

              Check the JS Console (Ctrl+J) for any error messages.

              • 4. Re: Image with Drop down in Adobe Acrobat X pro
                George_Johnson MVP & Adobe Community Professional

                I made a mistake for Option 3, it should be:

                 

                f3.display = display.visible;

                 

                Though that's probably not the problem.

                • 5. Re: Image with Drop down in Adobe Acrobat X pro
                  PYZ Level 1

                  It's still not working. The Image doesn't display at all.

                   

                  I have these 3 images where I use them as a button icon :

                   

                   

                  And I have these 3 option from dropdown box:

                  The image doesn't appear when I choose my selection and there are no error appear:

                   

                   

                   

                  This is the code I use:

                   

                  (function () {

                   

                      // Get references to the image buttons

                      var L1 = getField("Image1");

                      var L2 = getField("Image2");

                      var L3 = getField("Image3");

                   

                      // Hide all of the images

                      L1.display = display.hidden;

                      L2.display = display.hidden;

                      L3.display = display.hidden;

                   

                      // Show an image based on the selection

                      switch (event.value) {

                      case "Option 1" :

                          L1.display = display.visible;

                          break;

                      case "Option 2" :

                          L2.display = display.visible;

                          break;

                      case "Option 3" :

                          L3.display = display.visible;

                      }

                   

                  })();

                   

                   

                  Anything wrong with this?

                  Do you have any solution for this?

                  • 6. Re: Image with Drop down in Adobe Acrobat X pro
                    PYZ Level 1

                    I checked and there are no error messages.

                    • 7. Re: Image with Drop down in Adobe Acrobat X pro
                      George_Johnson MVP & Adobe Community Professional

                      It's because you have export values set for the dropdown items. The code assumes there are none. It also assumes the item values are "Option 1", "Option 2", and "Option 3", whereas you have "Item1", "Item2", and "Item3". So you'll have to modify things so they match up. If you want to use export values with the items, you'll have to change to using a custom keystroke script instead, but the code would also have to be modified a bit.

                      • 8. Re: Image with Drop down in Adobe Acrobat X pro
                        PYZ Level 1

                        Thanks for your immediate response!

                         

                        I have dropdown selection:

                        Image1, export value:L1

                        Image2, export value:L2

                        Image3, export value:L3

                         

                        and button images:

                        Image1

                        Image2

                        Image3

                         

                        So how should I modify the code to make it workable where I choose Image1 in my dropdown selection and only Image1 button is visible?

                         

                        Please help.