Good afternoon,
I've been trying to figure this out but haven't been able to, I'm hoping someone will come to my rescue.
I have a livecycle form that has two dynamic tables. The first table has a drop down box in the 5th column with two choices, "Controls are adequate" and "Controls are NOT adequate". If the users selects "Controls are NOT adequate" I would like the second table to add a new row and prefill the first column of that new row with the data entered into the first column of the first table. The second table is hidden until "Controls are NOT adequate" is chosen.
I tried the following in the change event of the first table's drop down box (column 5):
if (xfa.event.newText == "Controls are NOT adequate")
{
if(form1.FMAS102.presence == "hidden")
{
Form102.Table1.Row2.CorrProcessStep.rawValue = MainPag.Table1.Row2.ProcessStep.rawValue;
form1.FMAS102.presence = "visible";
}
else if(form1.Form102.presence == "visible")
{
form1.Form102.Table1.Row2.instanceManager.addInstance(1);
var cPStep = xfa.resolveNodes("form1.Form102.Table1.Row2.CorrProcessStep[*]");
for (var i=0; i <= cPStep.length-1; i++)
{
if(cPStep.item(i).rawValue == null)
{
xfa.resolveNode("form1.Form102.Table1.Row2.CorrProcessStep["+i+"]").rawValue = xfa.resolveNode("form1.MainPag.Table1.Row2.ProcessStep").rawValue;
}
}
}
}
The wierd thing is this code works as long as the user consecutively chooses "Controls are NOT adequate". The problem is when the user chooses the other choice for a couple of rows and then goes back to "Controls are NOT adequate" the new row is added but isn't prefilled.
Thanks in advance for any assistance you can provide.
There's also another detail that might help you out. The addInstance() function returns a pointer to the newly created row, so there is no need find it with resolve node.
Now, in general I don't think you've completely thought out your process. Rows are only added to the second table when a specific option is selected from the first table. There is a direct relationship between a row in the first table and the created row in the second table. There are two issues here that have to be resolved. The first is how the relationship is made. How do you identify which row in the second table is related to which row in the first table? For example, if the user changes their mind and selects "Controls are Adequate", doesn't the associated row in Table 2 need to be deleted? The other issue is ordering. The user can choose options from any row in the first table. They are not limited to selecting them in order. So, then how are the rows in the second table ordered?
Before writing the code you need to walk though all the different usage scenarios and develop a consistent approach to handling the interaction.
Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script