How to show hidden fields based on multiple inputs? | Community
Skip to main content
January 8, 2024
Solved

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.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Vijay_Katoch

Please go through the below example, you will get an idea about javascript.

 

https://help.adobe.com/en_US/livecycle/10.0/DesignerScriptingRef/WS92d06802c76abadb-3e14850712a151d270d-7ffa.html

 

2 replies

Vijay_Katoch
Community Advisor
Vijay_KatochCommunity AdvisorAccepted solution
Community Advisor
January 9, 2024

Please go through the below example, you will get an idea about javascript.

 

https://help.adobe.com/en_US/livecycle/10.0/DesignerScriptingRef/WS92d06802c76abadb-3e14850712a151d270d-7ffa.html

 

kautuk_sahni
Community Manager
Community Manager
January 18, 2024

@harthome 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.

Kautuk Sahni