These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Populate List Box from External File

srprice
Registered: Sep 19 2007
Posts: 138

I have created a Javascript List Dialog Box that executes through a button. This list contains specific data that I have hard-coded into the script. What I would like to do is have the list populate from an external file. That way a user can go in and update the file and no script change would be required.

Can this even be done?? If so can you point me in the right direction.

Thanks in advance for your response

Sarah

My Product Information:
Acrobat Pro 8.1.2, Windows
George_Johnson
Online
Expert
Registered: Jul 6 2008
Posts: 1876
Are you using Acrobat or Designer to create the form fields?
srprice
Registered: Sep 19 2007
Posts: 138
I'm writing the Javascript in Acrobat Professional 8.

Sarah
George_Johnson
Online
Expert
Registered: Jul 6 2008
Posts: 1876
You can use an FDF file to import items for a list box. In your case, are you using any export values for the list items?

George
srprice
Registered: Sep 19 2007
Posts: 138
This is a list box I created using javascript. Here is a sample of the code. I want to be able to populate the sub1 where it says "Test" and "Test1" from and external file.

var myDialog =

{
initialize: function(dialog)
{
dialog.load({
"sub1":
{
"Test": -1,
"Test1": -2,
}
});
},
commit: function(dialog)
{
//Retrieve the value stored in the list_box sub1:
var elements = dialog.store();

//Iterate through items and take actions as needed
for (var e in elements["sub1"])

//If the value is positive, it was selected:
if (elements["sub1"][e] > 0)
{
//app.alert("You chose:\n\n" + e, 3);

rc = elements["sub1"][e];
ListHandler(rc);
}
},

description:
{
name: "Dialog",
elements:
[
{
type: "view",
align_children: "align_left",
elements:
[
{
type: "cluster",
name: "Checkers",
elements:
[
{
type: "static_text",
name: "Select Name",
font: "default"
},
{
type: "list_box",
item_id: "sub1",
width: 200,
height: 100
},

]
},
{ type: "ok_cancel" }
]
}
]
}
};

function ListHandler (rc)
{
switch (rc) {
case 1:
var f = this.getField("Checked_By");
f.value = "Test";
break;
case 2:
var f = this.getField("Checked_By");
f.value = "Test1";
break;
default:
app.alert ("Invalid selection");
break;
}
George_Johnson
Online
Expert
Registered: Jul 6 2008
Posts: 1876
I'm sorry, I misunderstood what you were talking about. I thought you were asking about a list box form field, not a list box in a custom dialog.
srprice
Registered: Sep 19 2007
Posts: 138
No problem. I figured thats why I put in the sample code.

Thanks,

sarah
GovDev
Registered: Jun 8 2010
Posts: 5
Has any body found the answer to this question?

Thanks.

Kyle
try67
Expert
Registered: Oct 30 2008
Posts: 2398
Hi Kyle,

I've created a script that allows you to do just what the original poster described:
http://try67.blogspot.com/2009/11/acrobat-import-text-file-to-drop-down.php

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

GovDev
Registered: Jun 8 2010
Posts: 5
I wanted to dynamically populate a listbox in a custom Acrobat dialog from a data connection during run-time, not populating xfa listboxes (for which I already made a program for).

Thanks for the quick reply though.

Kyle
try67
Expert
Registered: Oct 30 2008
Posts: 2398
My script is not for populating xfa list-boxes, but for Acrobat forms.
It doesn't work in real-time, though, that's true. If you're using a version of Acrobat prior to X, I could probably create for you a script that connects to your DB and populates the box in real-time.
Contact me personally if you're interested...

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

GovDev
Registered: Jun 8 2010
Posts: 5
That's fine thanks. I figured it out.

Kyle