Hello,
I have a basic flowed structure that has a number if checkboxes each contained within a parent subform. My goal is to have a button at the end to check for all unchecked values and hide their parent subform. Sadly, I am unable to get it to work and I would really like some help with this.
Solved! Go to Solution.
Views
Replies
Total Likes
I think I see what you were trying to do, try something like this
checkAllNodes(Page1); function checkAllNodes(pNode){ var oNodes = pNode.nodes; var nodesLength = oNodes.length; for (var i = 0; i < nodesLength; i++) { //xfa.host.messageBox(oNodes.item(i).className) if (oNodes.item(i).className === "subform") { checkAllNodes(oNodes.item(i)); } if (oNodes.item(i).name === "chkCheckbox") { if (oNodes.item(i).rawValue === 0) { oNodes.item(i).parent.presence = "hidden"; } } } }
Probably best to put those Subforms (OptionA, OptionB, etc) under their own Subform and start recursion from it rather than Page1.
You can directly check for the raw value of the field and apply the presence based on the same.
var checkboxes = xfa.resolveNodes("chkCheckBox"); if(checkbox.rawValue == "0") { [parent subform].presence = "hidden"; } break;
If the subforms are static then you could do the following:
if (Page1.OptionA.chkCheckbox.rawValue === 0) { Page1.OptionA.chkCheckbox.parent.presence = "hidden"; } if (Page1.OptionB.chkCheckbox.rawValue === 0) { Page1.OptionB.chkCheckbox.parent.presence = "hidden"; }
I think I see what you were trying to do, try something like this
checkAllNodes(Page1); function checkAllNodes(pNode){ var oNodes = pNode.nodes; var nodesLength = oNodes.length; for (var i = 0; i < nodesLength; i++) { //xfa.host.messageBox(oNodes.item(i).className) if (oNodes.item(i).className === "subform") { checkAllNodes(oNodes.item(i)); } if (oNodes.item(i).name === "chkCheckbox") { if (oNodes.item(i).rawValue === 0) { oNodes.item(i).parent.presence = "hidden"; } } } }
Probably best to put those Subforms (OptionA, OptionB, etc) under their own Subform and start recursion from it rather than Page1.
This script will work with any name for the checkbox
checkAllNodes(Page1);
function checkAllNodes(pNode){
var oNodes = pNode.nodes;
var nodesLength = oNodes.length;
for (var i = 0; i < nodesLength; i++) {
if (oNodes.item(i).className === "subform") {
checkAllNodes(oNodes.item(i));
}
if (oNodes.item(i).className === "field") {
if (oNodes.item(i).ui.oneOfChild.className == "checkButton") {
if (oNodes.item(i).rawValue === 0) {
oNodes.item(i).parent.presence = "hidden";
}
}
}
}
}
Views
Likes
Replies