Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

How Do I: Fill a read-only field based on selections from 2 DDlists?

Avatar

Level 2

Follow-up from issue:  

http://forums.adobe.com/message/2417876#2417876

I have 2 drop-down lists...  "Department" and "SubDepartment"

The selection in DDlist "Department" spawns a unique list in DDlist "SubDepartment"

I select the proper items from both DDlists.

When I do this, I want read-only text field "NameOnIDBadge" to be populated with a pre-defined entry.

Example:

In "Department" DDlist, select item "Finance & Administration"

In "SubDepartment" DDlist, select item "Food Service" from the list that appears

THEN:

In read-only text field "NameOnIDBadge" the following predefined read-only text appears:  "Contract Food Serv."

(Thanks to Paul, I already know how to make the selection in DDlist "Department"  affect the selection list in DDlist "SubDepartment"

but I don't know how to make the selection of both DDlists create a new pre-defined entry in a text field.)

I have attached a mockup of the file I am working with...

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

if ((firstDDList.rawValue="Whatever") && (secondDDList.rawValue = "Whatever"))

yourTextBox.rawValue="the right text"

this code would go under the second DDList Exit event, replace the code i put in there to add the check of the first DDList

View solution in original post

7 Replies

Avatar

Former Community Member

yourtextBox.rawValue="Contract Food Serv."

see attached

Avatar

Level 2

I tried that but a few things went wrong.

1. After I select "Food Service" in the second "SubDepartment" DDlist, a Javascript error message pops up (see attached), and I have to click it to make it go away.  Then the text "Contract Food Serv" appears in the text box.

2. If I select a different value in the Department DDlist, the rawtext still remains in place... it should clear out.

3. The raw text seems to be based on the selection of the SubDepartment DDlist only.  However, I need specific raw text to be generated based on the combination of BOTH DDlists.   (It could happen that a totally different Department DDlist could have the same item in its corresponding SubDepartment DDlist.  In that case, the rawtext would be completely different.)

Correct example:

Department DDlist = Finance & Administration

SubDepartment DDlist = Food Service

NameOnIDBadge = Contract Food Serv  <-- CORRECT

Incorrect example:

Department DDlist = Clinical Services

SubDepartment DDlist = Food Service

NameOnIDBadge = Contract Food Serv   <--  INCORRECT   (it might be something else)

Avatar

Former Community Member

its not an error message, its a pop up i've put in place to check what's selected, and to make sure the logic works corrently, you can remove it from code.

to clear the text, put

yourtextboxname.rawValue = ""

on the exit event of the first drop down, etc.

have you looked at the code at all?

Avatar

Level 2

Thank you for your response.

I am a novice at learning code at this point, but yes I did look at it.

The issue still remains that the rawtext is triggered by the selection from the second SubDepartment DDlist only... not based on the combination of both DDlists.

Avatar

Correct answer by
Former Community Member

if ((firstDDList.rawValue="Whatever") && (secondDDList.rawValue = "Whatever"))

yourTextBox.rawValue="the right text"

this code would go under the second DDList Exit event, replace the code i put in there to add the check of the first DDList

Avatar

Level 2

Excellent! 

I'll redo it and test... and post back.

Thank you!

Avatar

Level 2

Thank you for pointing me in the right direction.

The only changes I had to make was to add a double "==" in the scripting for the selections from the 2 DDlists.

(Using a single "=" would cause things to not work properly.)

if ((firstDDList.rawValue=="Whatever") && (secondDDList.rawValue=="Whatever"))

yourTextBox.rawValue="the right text"

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----