-
1. Re: Populate a drop down list using Javascript in Acrobat, not LifeCycle
George Johnson May 2, 2012 2:32 PM (in response to JDMAWoods)It's actually easier since you can use the setItems method: http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.752.html
-
2. Re: Populate a drop down list using Javascript in Acrobat, not LifeCycle
JDMAWoods May 3, 2012 5:52 AM (in response to George Johnson)Thank you, George, for your response. So, I'm reading through all the instructions on how this would work, but I'm having difficulty knowing where to put the code. I tried associating it with the "Actions" tab of the property, and with an "onFocus" run a JavaScript, but that creates an error. I also tried associating it with a "calculate" script, but I don't want the field calculated. Finally, I tried to just place the code in the "All Document Scripts" section, but apparrently I don't have the right syntax for that section either...
As I mentioned, I figured it out with lifecycle, but this "simple JavaScript editor" that is built in to Acrobat, is a little to non-descript for me.
Can you identify where I should setup this action?
Maybe point me to some better sample code?
Thanks!
-
3. Re: Populate a drop down list using Javascript in Acrobat, not LifeCycle
George Johnson May 3, 2012 7:01 AM (in response to JDMAWoods)It is 't clear to me when you need it to run. If you could provide more information about how you need this to behave, it would be helpful.
-
4. Re: Populate a drop down list using Javascript in Acrobat, not LifeCycle
JDMAWoods May 3, 2012 8:18 AM (in response to George Johnson)My apologies. I just want the data for my dropdown list to be obtained from a script (I'm assuming it must be a JavaScript) rather than manually add them to the Dropdown Properties / Options tab because I have a list of almost 400 entries to make. So, technically, I guess it could run on document open. I'm not dynamically changing the contents of the list. It is a fixed list.
-
5. Re: Populate a drop down list using Javascript in Acrobat, not LifeCycle
GKaiseril May 3, 2012 11:07 AM (in response to JDMAWoods)Unlike LiveCycle Designer, Acrobat allows the setting of multiple entires and their export value at one time. You can define an array of the option items and their optional export values and then use the field object's "setItems" method.
You could define the array as a document level variable and then have a document level function to load that array to the field. Once setup, one could use the JavaScript console to load the drop down box only as needed or call the function in a document level JS and load the drop down box each time the form was opened.
// define array of entries and export values for drop down array
// define array of states and abbreviations
var aStates = new Array(["Select State", ""],
["Alabama", "AL"],
["Alaska", "AK"],
["Arizona", "AZ"],
["Arkansas", "AR"],
["California", "CA"],
["Colorado", "CO"]);// function to load a combo/list box with an array of values
function LoadOptions(oField, aValues) {
var bResult = false;
// load array of values into field object
if(oField.type != "combobox" && oField.type != "listbox") {
app.alert("Load Options function requires a combobox or listbox", 0, 0);bResult = false;
} else{
oField.setItems(aValues); // set values
bResult = true;
}
return bResult;
} // end LoadOptions// load the data - comment out after updating when only doing array changes
LoadOptions(this.getFeild('Combo Box1'), aStates);I would keep this in the PDF because a list can always change and it is a real pain to maintain a combo box or list box if there are multiple changes and reordering of the list.



