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

Import Text to Drop-down list

danielyoung25
Registered: Apr 23 2007
Posts: 2

How do I import test data into a drop-down list in Adob Designer 7.0?

My Product Information:
Acrobat Pro 7.0.0, Windows
sconforms
Expert
Registered: Jul 10 2007
Posts: 92
Prior to Designer 7.1, which has a new Dynamic Binding feature that makes this all very easy (see [url=http://forms.stefcameron.com/2006/07/29/dynamic-properties/]Dynamic Properties[/url] for more info), you have to use some script to go find the data values that you want and add them to the drop down list.

Let's say you wanted to import the names of all the actors listed in the movieData.xml file that's part of my sample form in my [url=http://forms.stefcameron.com/2006/07/29/dynamic-properties/]Dynamic Properties[/url] article and add them to a drop down list.

The structure of the XML file is like this:

 Comedy


School of Rock


Jack Black


18:45  ...


 
When XML data gets imported into a form, it gets stored in the "xfa.data" object. That means that after import (or data merge), the "xfa.data" object will have a single child node "theatre" and that child node will, in turn, have multiple "movie" child nodes, etc.

Given this information, you can then insert a drop down list into your form and write a little script that will find all nodes and add their values to the drop down list as items.

In the drop down list's Initialize method, in JavaScript, you could write:

var oTheatreNode = xfa.data.theatre;var oActorNodeList = oTheatreNode.resolveNodes("movie[*].actor"); for (var i = 0; i < oActorNodeList.length; i++){this.addItem(oActorNodeList.item(i).value);}
Note that this won't give you a list of [i]unique[/i] actor names but you'll get the list nonetheless. If you needed it to be unique, then you would simply accumulate unique values into an array and then iterate through the array afterwards in order to add unique items to the list.

This will work if you specify a preview data file in the Form Properties dialog when you preview the form using Designer or if you load the form in Acrobat Standard/Pro and choose to import data. It will [b]not[/b] work, however, if you load the form in Reader unless you've Reader-Extended the form using [url=http://www.adobe.com/products/livecycle/readerextensions/]LiveCycle Reader Extensions ES[/url] in order to allow Reader to import data into that PDF.

Finally, if you were asking how to import data from a database or web service, then I would suggest you check-out the following articles: [url=http://forms.stefcameron.com/2006/10/12/displaying-all-records-from-an-odbc-data-connection/]Displaying All Records From an ODBC Data Connection[/url] and/or [url=http://forms.stefcameron.com/2007/05/21/connecting-to-a-web-service/]Connecting to a Web Service[/url].

Stefan Cameron obtained his bachelor's degree with Honors in Computer Science at the University of Ottawa and is a Computer Scientist working on Adobe's LiveCycle server products, in particular on LiveCycle Designer ES for the past 5 years.

sconforms
Expert
Registered: Jul 10 2007
Posts: 92
Once again, I'll try posting the XML structure (gotta love it when the preview doesn't show you exactly what you're about to post!):



Comedy
School of Rock
Jack Black
18:45

Stefan Cameron obtained his bachelor's degree with Honors in Computer Science at the University of Ottawa and is a Computer Scientist working on Adobe's LiveCycle server products, in particular on LiveCycle Designer ES for the past 5 years.

sconforms
Expert
Registered: Jul 10 2007
Posts: 92
Obviously, this isn't working. Unfortunately, you'll have to look at the XML file in the sample ZIP file from my [url=http://forms.stefcameron.com/2006/07/29/dynamic-properties/]Dynamic Properties[/url] article to get a feel for what I'm talking about.

Stefan Cameron obtained his bachelor's degree with Honors in Computer Science at the University of Ottawa and is a Computer Scientist working on Adobe's LiveCycle server products, in particular on LiveCycle Designer ES for the past 5 years.

Morabe
Registered: Nov 21 2006
Posts: 20
Can someone PLEASE help on this?

DEVELOPED in LiveCycle 8.05: We have 4 text fields and 4 drop-down fields that all populate from a web service which is activated from a 9th field (network login name). The 4 ddl fields populate with the employee's specific information from the data base as well as a list of all other names (in case a correction is required).

TESTED in Acrobat Pro 8.1.2: All but 1 of the 8 fields successfully return the employee's specific information and the additional ddlists. The division name drop-down field is not working, it will not return any data. And when any of the ddl fields are tested they fatally error-out and close the program.

I've included a small sampling of the code we are using for the login name field (please note we've added app.alerts just to see if the code was working - and they do function correctly):

----- form1.#pageSet[0].Page1.#subform[0].ddlDivision::initialize: - (JavaScript, client) ----------

WSScriptObj.LoadDdlFromDelimitedStr(txtDivisionResult.formattedValue, this );
app.alert("in init");

----- form1.#pageSet[0].Page1.#subform[0].ddlDivision::preOpen: - (JavaScript, client) -------------

// set the division drop down based on the dept.
app.alert("inside preopen");
//fire the webservice
xfa.connectionSet.getDivision.execute(0);
app.alert("after webservice");
// load the ddl from comma delimited string
WSScriptObj.LoadDdlFromDelimitedStr(txtDivisionResult.formattedValue, ddlDivision );
app.alert("after load delimited str");
WSScriptObj.SetDdlSelected(txtDivisionName.formattedValue,ddlDivision);
app.alert("after set ddl selected");

I can send the file if that will assist.