How to clear a single checkbox with button click?

Hey all,

I now need to clear a checkbox that exists in a form, not a repeat.

I have a ‘clear’ button which I’d like to clear all checks. I’ve tried to use a dynamic event that sets the value of the checkbox to 0 and even ‘’ - but I’m getting no luck.

Any ideas?

Hello @mgaussie
So you don’t want to reset the whole form, but just the checkboxes (all?) inside it?

Hi @Teodor :slight_smile:

I have one large form, and two use cases:

If a user clears the entire form, then i’d like to be able to clear all checkboxes within it.

If the user just wants to clear one section of the form, let’s call it ‘company_size’ that has 5 checkboxes within that form group, I have a button they can click to just clear the checkboxes for that form group of 5 checkboxes.

Can’t figure it out!

You can use javascript to check/uncheck checkboxes but this will not fire the change event of the checkbox, which is a problem in most cases - especially when a checkbox is used to filter data.

Maybe @patrick can suggest a good solution here, as we don’t have a “check” dynamic event for the checkbox controls.

1 Like

Ok, no problem. Not firing the event change would be ok for some of the form groups, but not all of them - so would ideally need an alternative solution or I’ll need to move away from check boxes for this, I guess if @patrick doesn’t have an suggestion.

Could you set the value of the checkbox to:


That way the value actually changes when the check event takes place leading to the on change event being fired. You would then just use:


to retrieve the useful part of the value

or you could do

dmx.bind:value="checkbox.checked ? 'somevalue' : '' "

Do you use the checkbox-group? You can then use the setValue action of it to set the group. For checking/unchecking a single checkbox use the select action on the checkbox.

Uncheck checkbox group:


Uncheck single checkbox:


Uncheck checkboxes with jQuery:

onclick="$('[name=company_size]').prop('checked', false)"
1 Like

I’m not using a checkbox-group - I found I couldn’t easily stack checkboxes in a column with the checkbox-group so opted to create individual checkbox inputs one on top of each other.

Hey @patrick - I ended up converting all checks to a group, and just customizing the code within them a bit - and then used this approach, it works great. Thanks!

If a checkbox group or a radio group stores the values as an array, then could I use the array tools such as .remove
Screenshot 2021-04-20 at 17.37.09
on a checkbox group.

if so does anyone have the correct syntax, as i have tried quite a few and it’s not working.

Will this help?


<div class="input-group col-sm-6" id="stat_osf" is="dmx-radio-group" dmx-show=" == 1">
	<div class="input-group-prepend">
		<div class="input-group-text"><i class="fas fa-tire fa-fw fa-lg"></i>O/S/F</div>
	<div class="btn-group btn-group-toggle d-flex flex-wrap flex-grow-1" is="dmx-repeat" data-toggle="buttons" dmx-bind:repeat="`menu_id`, 32, '==')"

		<label class="btn btn-sm btn-clear" dmx-bind:for="input_{{menu_id}}_0_osf" dmx-bind:id="stat_osf_label_{{menu_id}}_0" dmx-show="$index == 0">
			<input class="custom-control-input" type="radio" dmx-bind:id="input_{{menu_id}}_0_osf" dmx-bind:value="" name="stat_osf" value="0"><i class="fa-ban fas"></i></label>

		<label class="btn btn-sm btn-outline-secondary" dmx-bind:for="input_{{menu_id}}_{{menu_list_id}}_osf" dmx-class:active="menu_list_id ==">
			<input class="custom-control-input" type="radio" dmx-bind:id="input_{{menu_id}}_{{menu_list_id}}_osf" dmx-bind:value="menu_list_id" name="stat_osf"
				dmx-bind:checked="menu_list_id ==">{{list_label}}</label>

Hmm, maybe with some modification, it might give some further idea. Thank you.

If I could remove i single entry from a checkbox group value array it would be the simplest way, which is why I tried that first, but I may need to take a longer procedure to achieve it. Although I am indeed still trying to see if the remove may work.

So looks like there is no way I could find to remove a single item from a checkbox groups value, instead I had to

Add the checkbox group values into an empty array
<dmx-array id="arrWhere" dmx-bind:items="checkboxGroup.value"></dmx-array>

Them remove from the array itself. But it did work with minimal hassle, however i just imagined i could manually remove an item directly from the checkbox group array itself.