Skip to main content
Level 2
Mar 26, 2025 7:49 AM UTC
Solved

Show hide JS on dropdown for multiple values

Can i use the JS at /libs/cq/gui/components/authoring/dialog/dropdownshowhide/clientlibs/dropdownshowhide/js/dropdownshowhide.js for multiple values of the same dropdown.

For eg: I want a container to be shown when val1 is selected and also when val2 is selected in the dropdown. I have tried comma separating however this does not seem to work as per the blog at https://www.linkedin.com/pulse/aem-hideshow-drop-down-select-options-more-than-one-values-vikraman/

Mahedi_Sabuj
Mahedi_SabujAccepted solution
Community Advisor
Mar 26, 2025 7:05 PM UTC

/libs/cq/gui/components/authoring/dialog/dropdownshowhide/clientlibs/dropdownshowhide/js/dropdownshowhide.js supports showing or hiding fields based on a single dropdown option, it doesn't account for multiple selections. To achieve that functionality, a custom JavaScript solution is required.

You can check this: https://ms-29.com/aem/sites/show-hide-aem-dialog-fields-on-dropdown-selection

Mahedi Sabuj

3 replies

PRATHYUSHA_VP
Community Advisor
Community Advisor
Mar 26, 2025 2:11 PM UTC

Hi @zendarkke 

 

If your AEM cq:dialog structure is similar to what is expected for the custom JS to work, it should execute as expected

 

Debug the custom JS and compare the cq:dialog structure that aligns with the script

 

Thanks

Translate
Prathyusha - AEM Developer
arunpatidar
Community Advisor
Community Advisor
Mar 26, 2025 3:53 PM UTC

Hi @zendarkke 

You need to create a clientlibs with category 'cq.authoring.dialog' with below updated js

https://github.com/arunpatidar02/aem63app-repo/blob/master/js/dropdownshowhide-multifield-multivalued.js 

 

Please check the usage instructions in the first comment section of the above js file

Translate
Arun Patidar
Mahedi_Sabuj
Community Advisor
Mahedi_SabujCommunity AdvisorAccepted solution
Community Advisor
Mar 26, 2025 7:05 PM UTC

/libs/cq/gui/components/authoring/dialog/dropdownshowhide/clientlibs/dropdownshowhide/js/dropdownshowhide.js supports showing or hiding fields based on a single dropdown option, it doesn't account for multiple selections. To achieve that functionality, a custom JavaScript solution is required.

You can check this: https://ms-29.com/aem/sites/show-hide-aem-dialog-fields-on-dropdown-selection

Translate
Mahedi Sabuj