How to implement single selection for checkboxes

Hi there,

I have a checkbox selection implemented as below:

image

And sharepoint column created as below:

image

However, I only want to be able to select one selection, so when I select on one of the checkboxes, the other two checkboxes are disabled.

How do I achieve that in JavaScript?

Thanks,

Hello @jyou,

You can change the display choices property to Radio Buttons, thus a user can only select one option.
image

And no code is required.

hi @mnikitina ,

Unfortunately, the program I am working on doesn't support Radio Buttons. So I am wondering I can write code to limit to one selection only for the checkboxes? Thanks.

@jyou,

You can try out this code:

var options = $(fd.field('MultiChoice').$el).find('input[type="checkbox"]')
options.click(function(){
    var selectedOption = $(this).attr("value");
    fd.field('MultiChoice').value = [];
    fd.field('MultiChoice').value.push(selectedOption)
});

Hi @mnikitina ,

It works for me now. Thanks a bunch :grin: :grin:

1 Like