Show hide JS on dropdown for multiple values | Community
Skip to main content
Level 2
March 26, 2025
Solved

Show hide JS on dropdown for multiple values

  • March 26, 2025
  • 3 replies
  • 821 views

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/

Best answer by Mahedi_Sabuj

/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

3 replies

PRATHYUSHA_VP
Community Advisor
Community Advisor
March 26, 2025

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

arunpatidar
Community Advisor
Community Advisor
March 26, 2025

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

Arun Patidar
Mahedi_Sabuj
Community Advisor
Mahedi_SabujCommunity AdvisorAccepted solution
Community Advisor
March 26, 2025

/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