How to show hidden fields based on multiple inputs?
- January 8, 2024
- 2 replies
- 606 views
Hello, I have a form I am working on in AEM Forms Designer with 2 sections, section B contains many hidden fields that need to be made visible by the inputs in section A. These inputs are a combination of drop-downs, checkboxes, and a single fill-in (for dollar amount). The items in section B need to be made visible by some drop-downs as an OR, and for the checkboxes as an AND.
I can get the items to show when going to the drop-down and making them visible on change, but that hasn't been working for when other checkboxes need to be marked as well.
I also tried to use the calculate event on the questions themselves, like this for example. Item S2Q4 should show when the drop-down ACQTypedrop is either "1" or "2" AND when the checkbox GP is "1".
This.presence = (this.resolveNode("ACQTypedrop").rawValue == "1" || this.resolveNode("ACQTypedrop").rawValue == "2") && this.resolveNode("GP").rawValue == "1" ? "visible" : "hidden";
On the drop-downs and check boxes I have a code to recalculate when changed, which on testing other items, does cause other items that use codes similar to above to show, but only on items that aren't needed to be shown by section A (they're headers in section B that only show when questions under them show). So I know the this.presence type code works, just not with the above code itself.
xfa.form.recalculate(1);
I don't know JavaScript very well, I only understand really basic things (like IF statements and what || and && mean), so if you could please also explain how your answer works, it would be greatly appreciated and I will be better able to learn.
I will attach my WIP form in case my explanation wasn't clear enough.