Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

how to create dynamic dependent dropdownlist using ODBC in LiveCycle?

jr87794863
Level 2
Level 2

I'm creating a user form using Livecycle designer.Here i'm not able to implement cascaded dropdownlist using javascript. I'm using ODBC dataconnection for data binding.Able to bind all data in respective dropdowns but don't know how to use cascading.

I followed this link LiveCycle ES2 * Adobe LiveCycle Designer ES2  but is is not working.

28 Replies
_Bruce_Robertson
Level 10
Level 10

So what isn't working, the ODBC connection or your code to populate the dependent dropdown controls?  Can we see some of the code you are using or better still can you upload a copy of your form to a file sharing site and post a link to it in this thread.  Is you dependent drop down values populated by the one ODBC call or is there one per value in the first dropdown.

Regards

Bruce

jr87794863
Level 2
Level 2

Hi,

Please check the file and suggest some solution.Very urgently needed.Plzzz

_Bruce_Robertson
Level 10
Level 10

Hi,

You seem to be populating the presCity drop down list in the change event of the presState drop down list, but you still have the presCity drop down items bound to the data connection.

If this is fairly static information I would suggest storing it in the form at design time.  Would let you avoid the while ODBC thing.

Regards

Bruce

jr87794863
Level 2
Level 2

Hi,

No presCity is not static.It get the data from database. If i'll not bind the presCITY with dataconnection it goes blank.City is coming from same database but different Table.How can i do this dynamically. And please also check the Add instance of Education Table.It is added but not showing up. Please give some solution to both problems.Very urgently needed.Thanks in advance.

_Bruce_Robertson
Level 10
Level 10

Hi,

We may be having a bit of a language problem, I was wondering how often you will need to add a city value to a state and if you know all the states and all the cities in the states before the user opens the form then there are easier ways to setup the form than an ODBC connection.

Also, not sure why not setting the binding for presCITY makes it go blank, as your code in the presState change event will populate it?

Bruce

jr87794863
Level 2
Level 2

Hi,

How can i do this.could you please do some necessary changes in the form and send back.What i have written in the presSTATE Change is not working.and other than this please check the instance issue also.It will be a great help.Please.

_Bruce_Robertson
Level 10
Level 10

I wont be able to work on this for some time, but maybe this link will help LiveCycle Blog: Mehrstufige Dropdown-Liste//Multilevel dropdown list  if you want to continue with your current approach maybe this link will help http://forms.stefcameron.com/2006/09/29/selecting-specific-database-records/ 

I might have time later in the week, if you are still stuck, post some of the data from your tables so I can include it directly into your form.

jr87794863
Level 2
Level 2

Hi,

I have used the second link you provided by you http://forms.stefcameron.com/2006/09/29/selecting-specific-database-records/ but it gives error message Error: accessor 'xfa.sourceSet.city.#command.query.commandType' is unknown.

my code in 1st dropdown change

-----------------------------------------------

var sCategoryName = xfa.event.newText

var sCategoryId = $.boundItem(sCategoryName)

xfa.sourceSet.city.#command.query.commandType = "text"

xfa.sourceSet.city.#command.query.select =

  concat("SELECT * FROM Dist_Master WHERE Dist_Code = ",sCategoryId, " ORDER BY Dist_Name;")

 

xfa.sourceSet.city.open()

xfa.sourceSet.city.first()

_Bruce_Robertson
Level 10
Level 10

I think Stefan was using FormCalc, if you want to use JavaScript it would be something like;

xfa.sourceSet.city.resolveNode('#command').query.commandType

jr87794863
Level 2
Level 2

I am also using FormCalc in change event but javascript in initialize.And i have now used data dropdown list in both as mention in this article.

_Bruce_Robertson
Level 10
Level 10

Shouldn't the third line be;

var oDataConn = Ref(xfa.sourceSet.city)

oDataConn.#command.query.commandType = "text"

as per Stefan's sample or did that fail as well?

jr87794863
Level 2
Level 2

It gives Error: accessor 'xfa.sourceSet.city' is unknown. I think Stefan is displaying the dependent data in a Text field but i want to display the list of data in drop down.

jr87794863
Level 2
Level 2

Hi,

Please try to update my form.Attaching my sql server database script.Dropbox - script.sql .Please need very urgently.Thanks in advance.

_Bruce_Robertson
Level 10
Level 10

The original form you linked to had the city data connection with a capital C.

Have you change it or should your code be xfa.sourceSet.City ?

jr87794863
Level 2
Level 2

Hi,

Anyone have solution of this please suggest me.I have already attached my form and database script above.

_Bruce_Robertson
Level 10
Level 10

Hi,

Try something like this bit of code in the preOpen event of your city dropdown list, which basically loops though the City record set looking for matching state codes and populating the drop down list.

this.clearItems();

xfa.sourceSet.City.first();

while(!xfa.sourceSet.City.isEOF())

{

if (xfa.resolveNode("$record.City.state_DCode").value == xfa.resolveNode("Row1[0].presSTATE").rawValue)

{
  this.addItem(xfa.resolveNode("$record.City.Dist_Name").value,

               xfa.resolveNode("$record.City.Dist_Code").value);

}

xfa.sourceSet.City.next();

}

First you will have to remove the binding to this drop down list and remove the other code you have trying to populate the drop down list.

You will also need to change the EOF Action of the City Data View to "Stay EOF" or the isEOF() will never return true. This is on the last page of connection properties for the City connection.

You are using a very old version of Designer (at least 10 years old) and I can not make you form run at all.  I would strongly suggest upgrading.

Regards

Bruce

jr87794863
Level 2
Level 2

Hi,

Thank you for your reply. I'll try the code and let you know. This designer version is provided by my office. can i upgrade it for free.

jr87794863
Level 2
Level 2

As i'm using Data Dropdownlist for both state and city it is already mentioned in initialize event.

var sBOFBackup = oDB.nodes.item(nDBIndex).query.recordSet.getAttribute("bofAction");

var sEOFBackup = oDB.nodes.item(nDBIndex).query.recordSet.getAttribute("eofAction");

oDB.nodes.item(nDBIndex).query.recordSet.setAttribute("stayBOF", "bofAction");

oDB.nodes.item(nDBIndex).query.recordSet.setAttribute("stayEOF", "eofAction");

Do i need to use this in preOPEN also.

_Bruce_Robertson
Level 10
Level 10

There's no need to use a Data Dropdownlist for the city control, as you will now be populating the values by code, just use the normal dropdown list.

The code above, setting the bofAction and eofAction values would be the same as setting them in the connection properties, just right click on the City data connection in the Data View palette and click next to the last (or third) dialog.  I would do this in the connection properties, and not use this code.

I don't know the know the pricing structure for LiveCycle Designer, probably depends on your office's contract with Adobe.  But you could try a free trail.