Expand my Community achievements bar.

Drop-down list problem

Avatar

Level 4

This code isn't working. I'm trying to use the data entered into instances of assessment.Objectives.objectivesdetail.objectivesdetail to populate the dropdown lists later in the form.

assessment.Objectives.objectivesdetail.objectivesdetail::exit - (JavaScript, client)

xfa.form.assessment.Questions.Questionset.Questiondetail.MCdetail.qObjlist.addItem(this.rawValue);
xfa.form.assessment.Questions.Questionset.Questiondetail.Matchingdetail.qObjlist.addItem(this.rawValue);
xfa.form.assessment.Questions.Questionset.Questiondetail.SAdetail.qObjlist.addItem(this.rawValue);
xfa.form.assessment.Questions.Questionset.Questiondetail.Essaydetail.qObjlist.addItem(this.rawValue);
xfa.form.assessment.Questions.Questionset.Questiondetail.MSdetail.qObjlist.addItem(this.rawValue);
xfa.form.assessment.Questions.Questionset.Questiondetail.TFdetail.qObjlist.addItem(this.rawValue);
xfa.form.assessment.Questions.Questionset.Questiondetail.orderingdetail.qObjlist.addItem(this.rawValue);
xfa.form.assessment.Questions.Questionset.Questiondetail.FIBdetail.qObjlist.addItem(this.rawValue);

10 Replies

Avatar

Former Community Member

The correct expression to add items to the DDList will have an occurance number on the repeating subform name. So if you wanted to add items to the 4th occurance of the subform with the DDName in it then it woudl be.....

xfa.form.assessment.Questions.Questionset.Questiondetail.MCdetail[3].qObjlist.addIt em(this.rawValue);

Note that the indexes are 0 based. If no occurance is given then the 1st occurance is assumed. Also the [] notation messes up javascript because it thinks you are referenceing an array so you must put your expression into an xfa.resolveNode('string") format. Typically the ocuurance number is assigned to a variable  so generally the exppressions tend to look like this:

xfa.resolveNode("xfa.form.assessment.Questions.Questionset.Questiondetail.MCdetail[" + i + "]").qObjlist.addIt em(this.rawValue);

Paul

Avatar

Level 4

Thank you for your response. I added this code:

assessment.Objectives.objectivesdetail.TextField1::exit - (JavaScript, client)

xfa.resolveNode("xfa.form.assessment.Questions.Questionset.Questiondetail.MCdetail[0]").qObjlist.addItem(this.rawValue);
xfa.resolveNode("xfa.form.assessment.Questions.Questionset.Questiondetail.MCdetail[1]").qObjlist.addItem(this.rawValue);
xfa.resolveNode("xfa.form.assessment.Questions.Questionset.Questiondetail.MCdetail[2]").qObjlist.addItem(this.rawValue);
xfa.resolveNode("xfa.form.assessment.Questions.Questionset.Questiondetail.MCdetail[3]").qObjlist.addItem(this.rawValue);

This should work to add the choices to the dropdown lists of the first four occurrences of the subform, right? I don't know how to assign a variable. If I did this code right, it's still not working. I have attached my form. To recreate, add some objectives. Then click Add a Question Set and then click Multiple Choice to see the MCdetail subform.

Thanks,

Tianna

Avatar

Former Community Member

Your issue is that the Questiondetail subform is repeating and should have the occurance numbers not MCdetail. I assuming taht you are only testing and that you will not hardcode the subform occurances in the expression when you are done ...right?

Paul

Avatar

Level 4

Oh, Paul. I really wish you could assume things like that, but, unfortunately, you can't. I am newbie. And by "newbie" I mean "right out of the chute." This is not only my first foray into LiveCycle, it is my first experience using JavaScript. This form represents the knowledge I have been able to get from how to sites and forums. So, any hand-holding you can do will be greatly appreciated, and I promise to try to help others on this forum when I have enough know-how to be of some help.

Avatar

Former Community Member

So by adding the occurance numbers on the right subform your code will work but it will not make sense. If I only add one objective then your code will generate errors when it tries to address the other 3 DDList - that do not exist. Do you see your users adding objects first and then questions or quetions then objectives? The answer to this will tell us which event to execute the code on. In either case the code will get more compicated as we will have to know how many subforms we have of each and then create a large complicated expression to add the information to the DDLists.

Paul

Avatar

Level 4

They will add all the objectives and then the questions. I want their only options in the question subforms to be objectives they have already entered. The problem is there is no way of knowing how many questions (subforms) there will be. It will vary each time the form is filled out. Is there a better way to execute this?

Avatar

Former Community Member

You cannot add the objectives to the DD lists until they exist (the questions have been added) so putting th ecode on the exit event of the objective does not make sense. You could have the code execute when you add the question subform this way you are only adding objectives once. The code will be tricky because of the timing of when the objects actually exist. You shoudl also disable the ability to add more objectives once the 1st question is added otherwise you will have to write code to handle the addition of more objectives later.

Make sense?

Paul

Avatar

Level 4

Yes, that makes sense. Unfortunately, I don't know how to do any of that. I really appreciate your help with this and all my other questions. I have learned a lot. I don't want to abuse this forum resource by continuously asking you to write my code for me. Can you point me to a resource online or a good book where I might learn these coding principles?

Avatar

Former Community Member

There are a number of good books that have been written ....one by JP Terry comes to mind but there are others. I would do a web serach for LiveCycle Designer books and see what comes up.

Paul

Avatar

Level 4

This is what worked, thanks to Niall (http://forums.adobe.com/message/2340926#2340926):

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);
}