Expand my Community achievements bar.

SOLVED

populating dropdown from multiple instances of subform

Avatar

Level 4

I have a dropdown list xfa.form.assessment.Questions.Questionset.Questiondetail.FIBdetail.qObjlist

That I want to populate with the text from all instances of the text field xfa.form.assessment.Objectives.objectivesdetail.objective.

The user determines how many instances of xfa.form.assessment.Objectives.objectivesdetail there will be.

How can I write the addItem for the dropdown list to grab the data from all the instances of xfa.form.assessment.Objectives.objectivesdetail?

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

I tried to have the exit field of the objective texfield populate the dropdown items, but it didn't like it if the "Fill in blanks"was hidden. So I have the following javascript in the enter event of the "Fill in blanks" dropdown instead. This look back at the objectives and loops through them:

this.clearItems();

this.rawValue = null;

var nCount = Objectives.objectivesdetail.instanceManager.count;

console.println("nCount: " + nCount);

for (var i=0; i<=nCount; i++)

{

     var vFld = xfa.resolveNode("Objectives.objectivesdetail[" + i + "]");

     var vObj = vFld.objective.rawValue;

     Questions.Questionset.Questiondetail.FIBdetail.qObjlist.addItem(vObj);

}

There are a few potential problems with the form, that show up in the javascript console. You should check these out.
I hope that helps.
Niall

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

Hi,

I tried to have the exit field of the objective texfield populate the dropdown items, but it didn't like it if the "Fill in blanks"was hidden. So I have the following javascript in the enter event of the "Fill in blanks" dropdown instead. This look back at the objectives and loops through them:

this.clearItems();

this.rawValue = null;

var nCount = Objectives.objectivesdetail.instanceManager.count;

console.println("nCount: " + nCount);

for (var i=0; i<=nCount; i++)

{

     var vFld = xfa.resolveNode("Objectives.objectivesdetail[" + i + "]");

     var vObj = vFld.objective.rawValue;

     Questions.Questionset.Questiondetail.FIBdetail.qObjlist.addItem(vObj);

}

There are a few potential problems with the form, that show up in the javascript console. You should check these out.
I hope that helps.
Niall

Avatar

Level 4

This worked great! I used it in all the subforms:

this.clearItems();
this.rawValue = null;

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

for (var i=0; i<=nCount; i++)
{
     var vFld = xfa.resolveNode("Objectives.objectivesdetail[" + i + "]");
     var vObj = vFld.objective.rawValue;
    this.addItem(vObj);
}

Thank you, thank you!