Requesting assistance to debug on calculate event for a numeric field to change the numbering if the subform is visible or hidden, I have the following code in the numeric field on the calculate event:
form1.PageOneSub.Subform1.SectionNumber::calculate - (JavaScript, client)
var visibleIndex = 1;
for (var i = 0; i < parent.classIndex; i++) {
var section = parent.classAll.item(i);
if (section.presence == "visible") {
visibleIndex++;
}
}
form1.PageOneSub.Subform2.SectionNumber::calculate - (JavaScript, client)
var visibleIndex = 1;
for (var i = 0; i < parent.classIndex; i++) {
var section = parent.classAll.item(i);
if (section.presence == "visible") {
visibleIndex++;
}
}
While the code above works and displays the numbering from 1 on, and, is correct for the subforms; any hiding of existing subforms does not trigger an update to the numbered list.
I have used the start of the index at 1 as otherwise it will display 0 in the first instance.
My subforms are uniquely named and are not iterations as they have custom content and may display based on other answers or button clicks.
Thank you in advance...
Solved! Go to Solution.
Views
Replies
Total Likes
You need to tell the form to start a recalculation, since this is only triggered automatically through changed values but not the presence of objects. Add this code to the existing script that controls the presence of your subforms.
xfa.form.recalculate(true);
You need to tell the form to start a recalculation, since this is only triggered automatically through changed values but not the presence of objects. Add this code to the existing script that controls the presence of your subforms.
xfa.form.recalculate(true);
This would be on the button to show a section or hide a section, is this correct? I had tried the recalculate and relayout functions previously, however, I may not have executed this script on the action button click event. I will try this to follow the JavaScript to hide or show a subform on the same button click event. Will reply with results.
I appreciate your input, sir.