Expand my Community achievements bar.

July 31st AEM Gems Webinar: Elevate your AEM development to master the integration of private GitHub repositories within AEM Cloud Manager.

Checkboxes in Licecyle

Avatar

Former Community Member
I know if you use radio button group then the user can only check one box out of whatever many is in the group. But say if your using 4 checkboxes but you want the user to be only allowed to pick one then I am assuming you have to use code. Now do you use FormCalc or Javascript? and then what is the code to do that? Basically if they click on checkbox1 then checkbox2, 3 and 4 should be blank then if they click on checkbox2 then checkbox1, 3 and 4 should be blank.
5 Replies

Avatar

Former Community Member
You cna write code or an easier way is to use radiobuttons and change their appearance to look like checkboxes. In the Object Paltte under the field tab there is an appearance dropdown. Change it to a solid square and voila ....mutually exclusive checkboxes.



Hope that helps

Avatar

Former Community Member
This is the Javascript code I put in to test the chickboxes in the "click" event but it still does not work. This is for first CheckBox1.



document.getElementById("CheckBox2").checked=false;

document.getElementById("CheckBox3").checked=false;

document.getElementById("CheckBox4").checked=false;

Avatar

Former Community Member
Try the following javascript:

if(CheckBox1.rawValue ==1)

{

CheckBox2.rawValue =0

CheckBox3.rawValue =0

CheckBox4.rawValue =0

}

remember to save as dynamic pdf.



I hope this helps you.

Avatar

Former Community Member
Thank You Daniel this worked perfectly. I know you can use radio buttons to this but the form I was working on was very old and contained subforms within subforms and it was just a mess. When I use the radio buttons it just doesn't join them in a group so I had to use checkboxes and this code works exactly fine with the click function. Thanks again.

Avatar

Former Community Member
You're welcome. Glad it solved your problem.