0

I have to create a dynamic drop down using AEM 6.4 where States need to be populated based on the Country Selected and it must be authorable.

I have used the below code where if the part is not working. Can anyone guide in reading the country value?

<body>
   <div id="country">${properties.country}</div>
   <div id="usaStates">${properties.usastates}</div>
   <div id="indianStates">${properties.indianstates}</div>
   <script>
   var countryName=document.getElementById("country").innertext;
   if(countryName=="India")
   {
     document.getElementById("usaStates").style.visibility = "hidden";
   }
   else
   {
     document.getElementById("indianStates").style.visibility = "hidden";
   }
   </script>
</body>
Nelson G.
  • 5,145
  • 4
  • 43
  • 54
Geetha
  • 1
  • 1
  • Possible duplicate of [Event binding on dynamically created elements?](https://stackoverflow.com/questions/203198/event-binding-on-dynamically-created-elements) – Shabeer K Nov 29 '18 at 06:21
  • Sorry my question is different ! In CRXDE, I have created a component with cq:Dialog containing one drop down select containing countries India and USA and one dropdown with states of india and one with USA and linked them via show hide text value property. – Geetha Nov 29 '18 at 07:16
  • Now I need to validate in html javascript to display corresponding state values related to country while author selects from the drop down in Edit mode – Geetha Nov 29 '18 at 07:23
  • Can't you directly use HTL to check if the country is India? Why do you need a script for that? – Ramachandra A Pai Dec 09 '18 at 23:53

0 Answers0