Copy link to clipboard
Copied
Why in gods name do I need a button to populate a drop down from a list this should not be complicated........All I want to do is populate a the drop with a list of names and values I do not want to push a button....to load said values, I just want to use Java to point at the dang list so I do not have type each and everyone over. If anyone can help me it would be appreciated. I would like to if possible to simply put a script into the custom calc script box for the drop down list under the calculate tab if possible or be told I cannot do it. Currently I have an excel file with the values I would like in the drop down list. I would think but do not know that an array and a getfield or the like would work.
Thank you ahead of time LOL!
Copy link to clipboard
Copied
Use Javascript for this. You can't use Java in Adobe Acrobat.
Copy link to clipboard
Copied
Hi,
You don't need a button to populate a dropdown.
You must place a custom keystroke script with the "willcommit" and "changeEx" event properties as in my attached example.
if(!event.willCommit) {
if (event.changeEx!=0) {
for (var i=1; i<cells.length; i++) {
if (event.changeEx==cells[i][1]) {
this.getField("name").value=cells[i][0]+" "+cells[i][1];
...
break;
}
}
} else {
this.getField("name").value="";
...
}
}
The script to retrieve the data from the spreadsheet is at document level, so if you modify the spreadsheet, you will have to save, close then re-open pdf file.
Hope that will help you!
@+
Copy link to clipboard
Copied
Just execute the code from the JS Console.
Copy link to clipboard
Copied
The basic code is this:
this.getField("Dropdown1").setItems(["Default item", "Item 1", "Item 2", "Item 3"]);
If you want to import a list from an Excel file you can use this (paid-for) tool I've created:
https://www.try67.com/tool/acrobat-import-items-from-a-text-file-to-a-combo-box-or-list-field
Copy link to clipboard
Copied
Thank you I will forward this to my home computer and see if I can learn this... Unfortunately the govy folks get all excited about links etc. Again Thank you I will get busy...
Copy link to clipboard
Copied
So using this.getField and the .setItems how do I apply the value I want to have the dropdown choice to pass? So you have context I am making a dropdown list with the Plant names and the the related wetland code so for instance I choose Cattail, I want to pass OBL for Obligate to a textbox.
Again thank you for your patience with me.
Copy link to clipboard
Copied
To do that you need a 2D-array, like this:
this.getField("Dropdown1").setItems([["Default item", ""] , ["Item 1", "1234"], ["Item 2", "4567"], ["Item 3", "999"]]);
Copy link to clipboard
Copied
Perfect! THANKYOU these forums rock!