Copy link to clipboard
Copied
Hi,
I wonder if it is possible to dynamically populate a drop-down list.
Very basically, I have a drop-down field called "countries". There are some options like, France, Spain, England, etc. but not all the countries.
I would like a user to add an item to the list, but not to duplicate an already existing item in the list.
I have seen it is possible in LifeCycle Designer but I only have license for Adobe Acrobat Pro DC at the moment.
Copy link to clipboard
Copied
Read these articles:
https://acrobatusers.com/tutorials/js_list_combo_livecycle
https://www.pdfscripting.com/public/List-Field-Usage-and-Handling.cfm
Copy link to clipboard
Copied
Read these articles:
https://acrobatusers.com/tutorials/js_list_combo_livecycle
https://www.pdfscripting.com/public/List-Field-Usage-and-Handling.cfm
Copy link to clipboard
Copied
Thank you Thom for providing me very valuable articles corresponding particular needs.
I am trying to implement it buy using your example however I am stuck in very fist steps.
I basically created three form field (drop-down list) in Acrobat. Names:
Row1.AssemblySelect
Row1.PartSelect
Row1.Price
then I went to document JavaScript and I copied and pasted your code basically (please see below).
At the end I went to preview my doc, but fields are not populated. Could you please kindly point at what I am missing? I tried like a number of times.
//////test out////////
var oAssemblyParts = {
Chasis: [
["-","None"],
["Rear Bracket",205.95],
["Front Bracket",185.95],
["Long Support",44.95],
["Front Bearing",48.95]
],
Clutch: [
["-","None"],
["Plate 1",15.95],
["Plate 2",22.95],
["Inside Shaft",44.95],
["Outside Shaft",32.95]
],
Brake: [
["-","None"],
["Master Cylindar",139.95],
["Slave Cylindar",85.95],
["Pad",15.95],
["High Presure line",22.95]
],
Coolant: [
["-","None"],
["Pump",35.95],
["Thermostat",19.95],
["Coolant Line",8.95],
["Reservoir",17.95]
]
};
function SetPartEntries() {
if(event.willCommit) {
// Get the new parts list from the Master List
// Since the selection is being committed,
// event.value contains the Assembly name
var lst = oAssemblyParts[event.value];
// Clear the Parts list if there are no parts for the selected assembly
if( (lst != null) && (lst.length > 0) )
this.getField("PartSelect").setItems(lst);
else
this.getField("PartSelect").clearItems();
// We have a new parts lists and the first entry is
// is a non-selection, so clear the price field.
this.getField("Price").value = 0;
}
}
SetPartEntries();
//////test out////////
Copy link to clipboard
Copied
Use the full names of the fields in your code.
Copy link to clipboard
Copied
Thank you, you're right the names of the fields and the code was inconsistent.
So I updated my field names to:
AssemblySelect
PartSelect
Price
BUT, it is still not working. I think what I miss is being able to populate "AssemblySelect" field first. Because I see no correspondence in code. Am I mistaken?
Copy link to clipboard
Copied
There is a part of the process you did not mention, which is putting code in the Custom Keystroke script. The example shows the code needed there.
Also, make sure the field Options are set to "Commit selected value immediately".
And also you have to setup the entries in the first drop down manually. You could do this from code very easily, but if they don't change there is no point, unless you have several rows of dropdowns to fill. In that case you'll also need to modify the code to handle different row names. But that is another issue.
Copy link to clipboard
Copied
Thank you! I was missing "Custom Keystroke script".
Actually I don't have several rows, but I would like to connect several list-box like Continent>Country>Region>City>Town... Should I have better create a new question for the problem I face in that?
Copy link to clipboard
Copied
That requires a more complicated data-model. I've developed a tool that allows you to set up such "cascading" drop-downs easily, based on a spreadsheet. See: Custom-made Adobe Scripts: Acrobat -- Create Cascading Dropdowns
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more