Expand my Community achievements bar.

SOLVED

How to show hidden fields based on multiple inputs?

Avatar

Level 1

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.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor
2 Replies

Avatar

Correct answer by
Community Advisor

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

 

https://help.adobe.com/en_US/livecycle/10.0/DesignerScriptingRef/WS92d06802c76abadb-3e14850712a151d2...

 

Avatar

Administrator

@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