Pictures in (or conected to) dropdown menu?  SOLVED

Forum for the PDF-XChange Editor - Free and Licensed Versions

Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan

Post Reply
User avatar
siSINka
User
Posts: 40
Joined: Sun Apr 07, 2019 11:55 am
Location: Czech Republic

Pictures in (or conected to) dropdown menu?

Post by siSINka »

I have a form with dropdown menu "Dropdown1" and an empty place "Image1". In dropdown menu there are values "A" and "B". I'd like to see (my) "PictureA" in the "Image1" field when value "A" is selected, and "PictureB" when "B" is selected.

If there was a text instead of the picture I use this JavaScript:

Code: Select all

switch(this.getField("Dropdown1").value) {
    case "A":
        this.getField("Text1").value = "My text A";
        break;
    case "B":
        this.getField("Text1").value = "My text B";
        break;
        default:
        this.getField("Text1").value = "";
} 
Can something similar be done for pictures?
If so, how do I "get" individual images into the form?
If this is not possible, could it be solved by ("homemade") stamps?

Thanks for help!
User avatar
TrackerSupp-Daniel
Site Admin
Posts: 8440
Joined: Wed Jan 03, 2018 6:52 pm

Re: Pictures in (or conected to) dropdown menu?  SOLVED

Post by TrackerSupp-Daniel »

Hello siSINka,

This certainly would be possible, first you would need to import the relevant images to the document using Javascript. For an example, please see the attached document. This can be done throught the JS console (Ctrl+J) by entering the following:

Code: Select all

importIcon("IconName")
Note that the "IconName" is unique, if you import another image and give it the same name it will overwrite the old one. Running this script will open a file select dialog, where you can navigate to the image you wish to import.

Once the images are imported you can include them into the dropdown and image fields, as you can see in the attached document.
The Dropdown field will need to have a Custom Action in the Value Validation area setup, which will look similar to this:

Code: Select all

var idx = 0;
if (event.target.getItemAt(1, false) == event.value)
	idx = 1;

var inames = new Array("icon1", "icon2")
getField("ImageField").buttonSetIcon(getIcon(inames[idx]));
I hope this helps!
Attachments
changeIcons.pdf
(7.35 KiB) Downloaded 75 times
Dan McIntyre - Support Technician
Tracker Software Products (Canada) LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
User avatar
siSINka
User
Posts: 40
Joined: Sun Apr 07, 2019 11:55 am
Location: Czech Republic

Re: Pictures in (or conected to) dropdown menu?

Post by siSINka »

Thank you veru much!

Everything works, life is better now :D
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17824
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Pictures in (or conected to) dropdown menu?

Post by Tracker Supp-Stefan »

:D
Post Reply