Expand my Community achievements bar.

Populate Text Field Based On Drop-Down List Selection

Avatar

Level 2
New here, can someone help with the following;

Dropdown list > address info is based on list selection (address info is multiple lines "address, city, st, zip, phone"

So user is filling out a form, selects recipient, and the address info + phone populates on it's own (into a text box) based on the item selected in the drop down.

Thanks,
Todd
12 Replies

Avatar

Former Community Member

Todd,

The attached populates a list box and a text field from a drop-down. I think that is what you are asking for.

Steve

Avatar

Level 2

Hi Steve,

Not exactly what I'm looking for.

I guess I need to clarify. My form is connected to a DB via a dataconnection, I have a drop down list that is being populated from a column in the DB, I'd like to select a name from the drop down and once I make that selection I'd like the form to auto populate a text field with the address that is connected to the name in the DB.

Hope that makes sense?

Thanks,

Todd

Avatar

Level 2

Hi Paul,

Was there suppose to be a link? I don't see one?

Thanks,
Todd

Avatar

Level 2

Thanks Paul, I'll take a look and let you know.


Thanks,
Todd

Avatar

Level 2

Hi Paul,

I have tried the method in the link provided without any luck. I'm able to get the drop down list to populate via a dynamic property but not by using the method in the link.

The steps I took are outlined below

I created a data connection called "To" and linked to it using the following SQL statement:

SELECT row_id, name FROM cvd_contacts GROUP BY name;

In the Initialized event of the object (Data Drop Down List), I set the data connection name to "To", the hidden value column name to "row_id" and the display text column name to "name".

When I test the form I get nothing in the drop down list.

What I'm I doing wrong? Below is an image of the DB table I'm trying to pull from with column names

1.png

Avatar

Former Community Member

Normally when you write a SQL statement like that you only want 1 record back. So normally there is a where clause....something like:

Select * from tablename where rowid = "157"

This will return the secondrow of the table then you woudl bind each colum to th efield in question. The issue now becomes how to get the selection from the droplist inot the sqlstatement.

Select * from tablename where rowid = "'" + DDlist.rawValue + "'";

Note that the quotes are important and we re using doublequotes, singlequote, dounblequote ...to get single quotes aroound our DDList value.

Make sense?

Paul

Avatar

Level 2

Thanks Paul! I think that makes sense,

I'm assuming that I replace DDlist with the name of my drop down list object? So if my Drop Down List object name is "Name" so the where statemnet would read

rowid = "'" + Name.rawValue + "'";

I'm I on the right track?


Thanks,

Todd

Avatar

Level 2

Hi Paul,

We finally got this figured out, code is below.

var

nIndex = 0;

while

(xfa.sourceSet.nodes.item(nIndex).name != "Info2")

{

nIndex

++;

}

var

oDB = xfa.sourceSet.nodes.item(nIndex).clone(1); // the node pertaining to the data connection specified

//set up sql call to DB to get specifics about employee

oDB.nodes.item(1).query.setAttribute("text"

, "commandType");

oDB.nodes.item(1).query.select.nodes.item(0).value

= "Select address1, address2, city, state, zip, phone from CVD_Contacts where row_id = " + $.boundItem(xfa.event.newText);

//now connect to DB and get a record

oDB.open();

//close the connection when finshed

oDB.close();

Thanks,
Todd

Avatar

Level 1

Steve, this is exactly what I am looking for.  I want the user to pull down a location from a dropdown (New York, London, Shanghai) and have the Text Field autopopulate the address for that location.  If the user chooses New York, then the Text field populates:

Tina Fey

30 Rockefeller Plaza

New York, NY 10111

The example you posted looks like what I am looking for, but I cannot figure out how to link the two. 

This is my first foray into LiveCycle so any help would be appreciated.