DEV Community

jan
jan

Posted on

Want to Disable the checkboxes / grey them out.

I have a list which consists of checkboxes. My requirement is based on another array called options. My option array has 3 elements and for the first option all the checkboxes should be available, so I can check them based on my requirement. But for the remaining 2 options I have to disable a few checkboxes based on their Id's.


Enter fullscreen mode Exit fullscreen mode

if(event.value == 5){
var opt = this.state.checkoxesArray
{
opt = opt.map((obj) =>
{
if(obj.id === 1 || obj.id === 4 || obj.id === 6)
{
obj.disable = true;

                }
                return obj;
            }
Enter fullscreen mode Exit fullscreen mode
Enter fullscreen mode Exit fullscreen mode

This is how I disabled for my remaining 2 options. Here as of now I am unable to check a few checkboxes for value '5'. But I want to grey it out or remove them, for 2 options and enable all these for 1 option.

I am new to react. Thanks in advance.

Top comments (0)