How to use a Drop-down list to change Pictures?

_uacct = “UA-1416026-2″;
urchinTracker();

_uacct = “UA-1416026-1″;
urchinTracker();

Hello all, well this is a direct reference to a comment to that was on this site. ( So see, I do read them ), so the question was how to use a drop-down list to change an image in an Acrobat Form? Well click the more button to find out!

_uacct = “UA-1416026-2″;urchinTracker();_uacct = “UA-1416026-1″;urchinTracker();Ok I’m going to go right out and say it… jeezzz this is so hard…..Ok just got to let it out…Big deep breath…..Ok to have a Drop Down list select and show a certaingraphic within a form requires…………..a small amount of programming! Ok, I said it, yes you must write a little code to have it happen for you. Wow, I feel so cleansed! Invigorated even, because if you have the ability to write very basic conditional code, you will be able to get more things done much quicker! I’ll get off the soap box now and get on with it.This was a fun little task, because the Acrobat Designer is a very powerful program that allows you to be very flexible with your forms. There is a great resource for the Acrobat Designer Here and Here is a PDF of the Form Calc Users Ref. A must have for form creators! So here you go, I have also attached the finished form here for you to play with; Dropdown to Change Pix.

So let’s get started, First open the Adobe LiveCycle Designer (sorry Mac Users you do not have this one, I will show this process for standard Acroforms in a later post) and start a blank form.

  1. Drag and Drop a Drop-Down List drop-down-list.pngany where on the page
  2. Add a Text Field textfield.png under the Drop-Down List
  3. Under the Text Field add 3 Image Fields image-field.png (Hint, it is alway a good idea to name your fields)

Your form should look like this:

form1.png

Go in and add three images to the images fields, any thing is fine.You now need to open the Script Editor window by going to the Window pull down and select Script Editor, this will open a window that will allow you to add your code.Ok it gets tricky here so go slow;

  1. Select the Drop-down List you placed on your form
  2. Goto the Script Editor and select FormCalc as our language (on the right side) and where it says Show showevent.png pull down and select Change as the event
  3. Copy and paste the code below (Note: I changed the name of the image boxes)

    // Code written by Tim Huff – Business Development Manager for Acrobat Oct 5 2007
    // Populate a variable (sNewValue) with the Current Value of the Drop-down list using the newText event.

    var sNewValue = $.boundItem(xfa.event.newText)TextField1.rawValue = sNewValue;// Fill the Text box with what you got

    // Test your variable agaist the name of the Image Object. The names for each Image object is listed under the Image
    if (sNewValue == “Acrobat Logo”) then
    //Let’s hide the Acrobat Logo
    AcrobatLogo.presence = “invisible”;
    AcrobatPro.presence = “visible”;
    AcrobatPro.presence = “visible”;
    elseif (sNewValue == “Acrobat Pro Box”) then
    //Let’s hide the Acrobat Pro Box
    AcrobatPro.presence = “invisible”;
    Acrobat3D.presence = “visible”;
    AcrobatLogo.presence = “visible”;
    elseif ( sNewValue == “Acrobat 3D Box”) then
    //Let’s hide the Acrobat 3D Box
    Acrobat3D.presence = “invisible”;
    AcrobatLogo.presence = “visible”;
    AcrobatPro.presence = “visible”;
    elseif ( sNewValue == “All”) then
    // Ok for fun let’s hide’em all
    Acrobat3D.presence = “invisible”;
    AcrobatLogo.presence = “invisible”;
    AcrobatPro.presence = “invisible”;endif

Now you should be able to just click on the Preview PDF tab and run your code.That was pretty deep for a Monday morning, so have fun, don’t get to frustrated, check out the links I set up for you and you can download a version of the form here Form for Drop-down list to change images Have a good week, I am off to the PDF Central Conference, so try to put some life in your life, check out a soccer game on Fox Soccer Channel Let’s go FC Dallas! Go Cowboys!

Later allTim

If electricity comes from electrons, does that mean that morality comes from morons? – Unknown