Hi, I am building a dynamic form. Each section is wrapped in in a subform. two sections have subforms within a parent subform. ex. form1.headersubform.childsubform.child2subform. I have a button that on the click event uses javascript code to check for empty/null field and colors the fields yellow and sets another var which prevents signature. Everything works, except for the 2 and greater instances of child2subform. The fields in header subform color fine for every repeating instance. The child2subform within the headersubform only colors for the 1st instance.
I can't find the issue in the code to get the child2subform instance to color.
My Javascript
var DDSC = form1.headersubform.childsubform.child2subform.instanceManager.count;
for (var sprec = 0; sprec < DDSC; sprec++) {
for (i = 0; i < DDS.length; i++) {
// check for null or empty value
if (isEmptyField("headersubform.childsubform.child2subformd[" + sprec + "]." + DDS[i])) {
// change the field to required
this.resolveNode("fheadersubform.childsubform.child2subform[" + sprec +"]." + DDS[i]).ui.oneOfChild.border.fill.color.value = "255, 255, 153";
missingData = true;
} else {
// change the field to normal
this.resolveNode("fheadersubform.childsubform.child2subform[" + sprec +"]." + DDS[i]).ui.oneOfChild.border.fill.color.value = "255, 255, 255";
}
}
}
Solved! Go to Solution.
Views
Replies
Total Likes
Here is the code to check for empty field and revert the color of field to normal if not null.
For DDS[i], use it like the same you are using [" + sprec + "].".
It should work then.
Tried that, now no instances color when null. I am very new to javascript.
I tried
this.resolveNode("headersubform.childsubform.child2subform[" + sprec +"]." + DDS[" + sprec + "]).ui.oneOfChild.border.fill.color.value = "255, 255, 153";
Is that what you meant?
this.resolveNode("headersubform.childsubform.child2subform[" + sprec +"]." + "DDS[" + i + "]").ui.oneOfChild.border.fill.color.value = "255, 255, 153";
Result is the same - no instances of the child2subform color
Share your form, need to look into the form layout and script
I'd rather email as its a sensitive form than attach it here
Vkatoch07@gmail.com
On its way to you.
I have taken a button in your form and added below script in the click event:
This is the code to change the color of fields in parent and child subform. I have added for one field in parent form, you can add for other like I did for "DesignDesignationSR". You can also write your rest of logic. This will the base code to traverse your parent and child subform fields.
var oNodes = xfa.resolveNodes("DesignDesignation.Designation[*]");
var nNodesLength = oNodes.length;
for (var nNodeCount = 0; nNodeCount < nNodesLength; nNodeCount++) {
var cItem = oNodes.item(nNodeCount);
cItem.DesignDesignationSR.ui.oneOfChild.border.fill.color.value = "255, 255, 153";
var dNodes = cItem.resolveNodes("DesignSpeed.DesignSpd[*]");
var dNodesLength = dNodes.length;
for (var dNodeCount = 0; dNodeCount < dNodesLength; dNodeCount++) {
var dItem = dNodes.item(dNodeCount);
dItem.DesSpeed.ui.oneOfChild.border.fill.color.value = "255, 255, 153";
}
}
Thank you for the assistance - can you return the updated form for reference. Thank you again!
Here is the code to check for empty field and revert the color of field to normal if not null.
@TGD3 Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.
Views
Replies
Total Likes