Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.
SOLVED

3 checkboxes but only 2 at a time

Avatar

Level 2

Hi, so I have a form where the user needs to select 2 out of 3 possible checkbox choices. What I want it to do if you have selected for instance 1st and 2nd checkbox and then you change your mind and want the 3rd instead of 2nd I want it to delete the last selected checkbox and select the 3rd one. Whats the javacript for this? thanks

1 Accepted Solution

Avatar

Correct answer by
Level 2

Ok I've found an answear if anyone wants to know.

Put this Formcalc inside layout:ready event for the subform these checkboxes are in. So no code is neccesarry inside the checkboxes.

Heres the code for the layout:ready part

if (Sum(subform.checkbox2, subform.checkbox3) ge 2) then

    checkbox1.access = "readOnly"

else

  checkbox1.access = "open"

endif

if (Sum(subform.checkbox1, subform.checkbox3) ge 2) then

    checkbox2.access = "readOnly"

else

  checkbox2.access = "open"

endif

if (Sum(subform.checkbox1, subform.checkbox2) ge 2) then

    checkbox3.access = "readOnly"

else

  checkbox3.access = "open"

endif

View solution in original post

1 Reply

Avatar

Correct answer by
Level 2

Ok I've found an answear if anyone wants to know.

Put this Formcalc inside layout:ready event for the subform these checkboxes are in. So no code is neccesarry inside the checkboxes.

Heres the code for the layout:ready part

if (Sum(subform.checkbox2, subform.checkbox3) ge 2) then

    checkbox1.access = "readOnly"

else

  checkbox1.access = "open"

endif

if (Sum(subform.checkbox1, subform.checkbox3) ge 2) then

    checkbox2.access = "readOnly"

else

  checkbox2.access = "open"

endif

if (Sum(subform.checkbox1, subform.checkbox2) ge 2) then

    checkbox3.access = "readOnly"

else

  checkbox3.access = "open"

endif