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 to add a set number of instances based on number selected from a drop down

Avatar

Former Community Member

I have a form where I would like users to be able to select a number from a drop down, and that number of instances of a specific subform get displayed, eg if they select 3 from the drop down, 3 instances of the subform display. I'm a LiveCycle newbie, so can anyone help me with a simple way to do this?

1 Accepted Solution

Avatar

Correct answer by
Level 10

When a row is hidden when the form is created and you add instances of that row, it will add these rows as hidden because it is using the initial properties of the row.

You would have to set every rows which have been added to visible when they are created.

subform1.instanceManager.setInstances(5);

for (var i = 0; i < subform1.instanceManager.count; i++){

     var frmSub = Main.resolveNode("subform1[" + i.toString() + "]");

     frmSub.presence = "visible";

}

View solution in original post

4 Replies

Avatar

Level 10

to do so you can use the setInstances() method

subform1.instanceManager.setInstances(2);

if you want to make the number of instance out of a selection in a dropdownlist you can use its value to set the instances

subform1.instanceManager.setInstances(dropdownlist.rawValue);

Avatar

Former Community Member

Thanks Magus069, this works for me fine if the original instance of the subform is set to visible, but not when it is hidden (as I would want it to be in this form). Any suggestions for how to get around this?

Avatar

Correct answer by
Level 10

When a row is hidden when the form is created and you add instances of that row, it will add these rows as hidden because it is using the initial properties of the row.

You would have to set every rows which have been added to visible when they are created.

subform1.instanceManager.setInstances(5);

for (var i = 0; i < subform1.instanceManager.count; i++){

     var frmSub = Main.resolveNode("subform1[" + i.toString() + "]");

     frmSub.presence = "visible";

}

Avatar

Former Community Member

Thanks you so much. A little tweaking and I've got it working exactly how I want it now. Cheers.