Pictures in (or conected to) dropdown menu?  SOLVED

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

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

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 » Sat Apr 20, 2019 5:12 am

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: 2901
Joined: Wed Jan 03, 2018 6:52 pm

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

Post by TrackerSupp-Daniel » Mon Apr 22, 2019 6:22 pm

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 30 times
Daniel McIntyre
Support Technician
Tracker Software Products (Canada) LTD

Sales: +1 (250) 324-1621
Fax: +1 (250) 324-1623

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 » Tue Apr 23, 2019 9:21 am

Thank you veru much!

Everything works, life is better now :D

User avatar
Tracker Supp-Stefan
Site Admin
Posts: 13811
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

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

Post by Tracker Supp-Stefan » Tue Apr 23, 2019 9:22 am

:D

Post Reply