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

Adobe Summit 2023 [19th to 23rd March, Las Vegas and Virtual] | Complete AEM Session & Lab list
SOLVED

Prepopulate DDList

Avatar

Level 3

A form with two drop down lists.

First ddlist is called "Model"

List items are: Model1, Model2, Model3, & Model4

Second ddlist is called "Engines"

This has list items: Engine1, Engine2, Engine3, & Engine4.

How can I code this, so that when Model1 is selected in the first ddlist, the second ddlist only has list items "Engine1" & "Engine2" ?

(The only engine options available for Model1)

...and when Model2 is selected in the Model ddlist, the Engine ddlist only displays "Engine3" & "Engine4" ?

Not sure if this requires a script object, or an array of some kind? Either way, I am not sure how to do it, and would love some help from the experts!

Many Thanks

1 Accepted Solution

Avatar

Correct answer by
Level 10

The attached contains a sample with linked drop-downs for models and engines as described. It uses a combination of events and a script object.

Steve

View solution in original post

0 Replies

Avatar

Correct answer by
Level 10

The attached contains a sample with linked drop-downs for models and engines as described. It uses a combination of events and a script object.

Steve

Avatar

Level 3

This works fine, but I now need to make a subform visible when a particular engine selection is made.

Because there are no list items (as they are in the script object) is makes it hard to set an action on the engine ddlist to make the subform visible?

I was hoping to do something like:

if (xfa.event.newText == "Engine1") {
  this.resolveNode("subform1").presence = "visible";
}

Avatar

Level 10

Use this script in the layout ready:Event of the subform.

this.presence = DDL.rawValue == "Engine1"? "visible":"hidden";

Avatar

Level 10

Make sure you use JavaScript as script language.

Also, you may have to use the resolveNode method to resolve the full path of the DDL.

1.  Enter the script into the layoutReady:event of the subform and place the text cursor at the position with the x. (x does not belong to the script)

this.presence = x.rawValue === "Engine1"? "hidden":"visible";

2.  Now press and hold down ctrl + shift and move the mouse cursor over the DDL until a down arrow ˅ will appear, then click the left mouse button.

Designer will add the neccessary part to resolve the path to the DDL to your script.

this.presence = xfa.resolveNode("Form1.#subform.DDL").rawValue === "Engine1"? "hidden":"visible";

The ultimate experience is back.

Join us in Vegas to build skills, learn from the world's top brands, and be inspired.

Register Now