Skip to main content
Humming Wood
Participant
January 27, 2026
Answered

Switching out an image via dropdown menu (maybe with visibility?)

  • January 27, 2026
  • 2 replies
  • 98 views

Hi i am new at making PDF’s in Adobe Acrobat.

what i need is a dropdown menu which would allow you to change an image into another.. i have tried to get help from chatgpt with low expectations.. but it helped me get a basic understanding of how and that i need a script.. the problem is the script.. it made a script for me but it doesnt work so are there some script wizard in here who can give me a basic script or tell me how or were to find it.

 

Best Regards 

 - Mads

these images in the same place so only one of them is visible at a time.

    Correct answer ls_rbls

    Hi ​@Humming Wood ,

     

    That script works beautifully as it is.

     

    You didn’t mentioned where are you running the script from.

     

    Things to keep in mind when employing the switch(event.value) method in a dropdown menu:

    • Use your script as a custom keystroke script  => go to the “Format” tab => click on the “Edit...” button next tp the “Custom Keystroke Script:” editor, and place your script there
    • In the “Dropdown Properties” dialog window => Go to the “Options” tab and check the tickbox “Commit selected value immediately
    • ensure that your items listed in the Item List  are spelled exactly as the image button field names

     

    For your convenience, here is a shared copy of my pdf with your working script:

     

    https://acrobat.adobe.com/id/urn:aaid:sc:US:62cb9cb0-65bc-46d6-9082-368429427c12

     

     

    2 replies

    Humming Wood
    Participant
    January 27, 2026

    this is the code it gave me:
     

    // List all image buttons
    var imgs = [
      "img_1_min",
      "img_10_min",
      "img_1_hour",
      "img_8_hours",
      "img_1_day"
    ];

    // Hide all images first
    for (var i = 0; i < imgs.length; i++) {
      this.getField(imgs[i]).display = display.hidden;
    }

    // Show the selected one
    switch (event.value) {

      case "1min":
        this.getField("img_1_min").display = display.visible;
        break;
      case "10min":
        this.getField("img_10_min").display = display.visible;
        break;
      case "1hour":
        this.getField("img_1_hour").display = display.visible;
        break;
      case "8hours":
        this.getField("img_8_hours").display = display.visible;
        break;
      case "1day":
        this.getField("img_1_day").display = display.visible;
        break;
    }
     

    ls_rbls
    Community Expert
    ls_rblsCommunity ExpertCorrect answer
    Community Expert
    January 28, 2026

    Hi ​@Humming Wood ,

     

    That script works beautifully as it is.

     

    You didn’t mentioned where are you running the script from.

     

    Things to keep in mind when employing the switch(event.value) method in a dropdown menu:

    • Use your script as a custom keystroke script  => go to the “Format” tab => click on the “Edit...” button next tp the “Custom Keystroke Script:” editor, and place your script there
    • In the “Dropdown Properties” dialog window => Go to the “Options” tab and check the tickbox “Commit selected value immediately
    • ensure that your items listed in the Item List  are spelled exactly as the image button field names

     

    For your convenience, here is a shared copy of my pdf with your working script:

     

    https://acrobat.adobe.com/id/urn:aaid:sc:US:62cb9cb0-65bc-46d6-9082-368429427c12

     

     

    Humming Wood
    Participant
    January 30, 2026

    Thank you so much i did it the wrong way around! :) 

    Bernd Alheit
    Community Expert
    Community Expert
    January 27, 2026

    Use form field buttons for the images . You can show/hide the buttons.