Jun 03 2008
Dynamically populate dropdown lists using webservices
Disease:
How to dynamically populate a dropdown list in a pdf form with results from a webservice? Typically one can accomplish this by using lots of hidden fields to capture the webservice results, and write multiple lines of Javascript code to populate the dropdown list based on the values of these hidden fields. There is however a much shorter way!
Prescription:
LiveCycle Designer 8 offers a nice new functionality.
1) Select the dropdown list and go to the Object Palette.
2) There select the right most icon.
3) Since version 8 one can choose “Show Dynamic Properties”. The result of this is that “Caption” and “List Items” become links instead of just labels.
4) Choose “List Items” and bind the dropdown list items to the return value of the webservice (through the webservice dataconnection).
This is it.
One can go a step further. Suppose you want to select a value from this dropdown list, which needs to be used as input for a second webservice, which needs to populate on its turn a second dropdown list. The same applies for the second dropdown list.
1) Bind it dynamically to the result of the second webservice.
2) Make sure however that in this case you use execute(0) when writing the Javascript code to call the second webservice, and not execute(1). Execute(0) will make sure that the DOM is not remerged (with the risk that the first dropdown list gets empty again)
Tip to stay healthy:
Start questioning your code when you see your lines of code and your amount of hidden fields growing just to accomplish an easy population of lists. Chances are big that Designer offers a functionality to do this on the fly.

Hi,
I have 2 drop down list on my form (LC designer 8.2). Both of them is connected to Access databases. (Countries and cities.) I want to select country on first drop down list then I want to show just selected country’s cities on the second drop down list.
What I did till now is;
I wrote this on first drop down list’s “change” event
var sCategoryId = country.rawValue
var oDataConn = Ref(xfa.sourceSet.DataConnectionCOUNTRY.clone(1))
oDataConn.#command.query.commandType = “text”
oDataConn.#command.query.select = concat(”SELECT * FROM COUNTRY WHERE IL_ID = “, var sCategoryId)
oDataConn.open()
I don’t have any message but i doesn’t work? Do you have any idea?
Thank in advance..
Hi all,
We have solved the problem that I mention above.
You can find detailed information (example) about “dynamically populated dependent drop down lists using OLDB connection” from the link below.
http://blog.vukuf.com/2008/11/populating-drop-down-list-from-database.html
Thank you Peter (from Adobe Systems Benelux BV) for your cooperation and help
Hi Peter,
You said that, to dynamically populate a dropdown list in a pdf form with results from a webservice we need to create lots of hidden fields to capture the webservice results, and write multiple lines of Javascript code to populate the dropdown list based on the values of these hidden fields. How to do this ? I mean how to assign hidden field values to drop down list ?
Can we change the field label/name dynamically ?