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

Issue with a dynamic drop down based on subform instances

Avatar

Level 2

I am having an issue with a dynamic drop down based on subform instances.  Here is my issue:

Subform1 = Value 1 and is repeatable
Subform2 = Value 1 to Subform1 and is repeatable
Subform2 = Value 2 to Subform1
Subform2 = Value 3 to Subform1

Subform1 = Value 2 and is repeatable
Subform2 = Value 1 to Subform1 and is repeatable
Subform2 = Value 2 to Subform1
Subform2 = Value 3 to Subform1

I can populate my first drop down from Subform 1 values with the following:

var nCount = Subform1.instanceManager.count;
console.println("nCount: " + nCount);


for (var i=0; i<=nCount; i++)
{
     var vFld = xfa.resolveNode("Subform1[" + i + "]");
     var vVal = vFld.Val.rawValue;
    this.addItem(vVal);
}


This gives me Value 1 (Subform1) and Value 2 (Subform1)

I am now trying to populate a second drop down based on the selection from that drop down.

For example:

If Value 2 (Subform1) is selected in this drop down I want the secodn drop down to be populated with Value 1 (Subform2) and Value 2 (Subform2) and Value 3 (Subform2) for Subform1 Value 2.

I would appriciate any assistance I could get on this.

Thanks,
Eagle

1 Accepted Solution

Avatar

Correct answer by
Level 5

Hi,

Ah ok, so I think this is the one -- https://acrobat.com/#d=nddInIuQUwXMY8ciRPoOfw

Hope this helps

Malcolm

View solution in original post

8 Replies

Avatar

Level 10

Hi,

I can't get to Designer at the moment, but there are a few examples here that may show you how to use the preOpen event for the second dropdown. This would look back at the selected value for the first dropdown and then add the appropriate items to the second dropdown:

http://assure.ly/jcTahK and http://assure.ly/gcXx03.

I appreciate that these do not deal with the repeating instances, but you seem to have a handle on this aspect.

Good luck,

Niall

Avatar

Level 2

Actually, that is my issue.  I can get the values from Subform 1 with no problem.  I can get the values from subform 2 with no problem.  What I am having an issue with is getting the values for subform 2 that are associated with the same instance of subform 1.

var nCount = Subform1.instanceManager.count;
console.println("nCount: " + nCount);


for (var i=0; i<=nCount; i++)
{
var vFld = xfa.resolveNode("Subform1[" + i + "]");
var vVal = vFld.Val.rawValue;
this.addItem(vVal);
}

gives me the values for subform 1 in dropdown 1

var nCount = Subform2.instanceManager.count;
console.println("nCount: " + nCount);


for (var i=0; i<=nCount; i++)
{
var vFld = xfa.resolveNode("Subform2[" + i + "]");
var vVal = vFld.Val.rawValue;
this.addItem(vVal);
}

gives me the values for subform 2 but only for instance 1 of subform 1. 

Hope this makes sense.

Thanks,

Eagle

Avatar

Level 10

Sorry, but I don't get what you are trying to achieve.

Can you share your form? If you can upload it to Acrobat.com or another file sharing site, publish it and then share the published URL here.

There is an example of duplicating table data here: http://assure.ly/hw7lwM, which sets the value of an object in the same instance of another table. That may help.

Niall

Avatar

Level 2

Here is a copy of the form.  I would greatly appriciate any assistance....

http://www.xua-llc.com/dropdownform.pdf

Thanks,

Eagle

Avatar

Level 5

Hi,

Using your form I have modified the code on the 2nd dropdown so that the code now looks like

form1.#subform[0].Subform4.DD2::enter - (JavaScript, client)

   

this.clearItems();

this.rawValue = null;

//var nCount = Subform3.Subform2.Subform1.Controls.Control.instanceManager.count;

var sf1 = Subform3.Subform2.resolveNodes ("Subform1[*]");

for ( var i = 0; i < sf1.length; i++)

{

          var controlsf = sf1.item(i).resolveNodes ("Controls.Control[*]");

          for ( var j = 0; j < controlsf.length; j++)

          {

                    var wInput = controlsf.item(j).ItemInput.rawValue;

                    this.addItem(wInput);

          }

}

And this appears to do what you would like, attached is the modified file. https://acrobat.com/#d=2bCKjocMsBG29a8pz8jIQw

Hope this helps

Malcolm

Avatar

Level 2

Yes, and No...  I was able to do this before.  The second drop down shows ALL instances of the sub-items, I only want it to display the sub items associated with the Item selected in drop down 1.  For example if I have Item 1, sub-items 1 and  2 and Item 2, sub-item 3 and sub item 4 when I select item 1 in drop down 1 in drop down 2 I want to see only sub item 1 and 2 and if I select item 2 in drop down 1 I on;ly want to see sub item 3 and 4 in drop down 2.

This has been driving me nuts for three days.  I appreciate all the input.

Thanks,

Eagle

Avatar

Correct answer by
Level 5

Hi,

Ah ok, so I think this is the one -- https://acrobat.com/#d=nddInIuQUwXMY8ciRPoOfw

Hope this helps

Malcolm

Avatar

Level 2

BarlaeDC,

Thank you, Thank You, Thank You,

That is EXACTLY what I was trying to do......

Thanks Again,

Eagle