Checkbox selection with the label

Guys,
How do I make sure that clicking on the relevant word toggles the right checkbox? Anything in the properties I should adjust?

checkboxes

Make sure the for attribute of the label points to your checkbox id.

Thanks now my label for points to the ID of the checkbox yet it does not render the desired result. Anything to do with the Form Label option in the properties of the label?
image

Because of the repeat, you are assigning the same ID to each of the checkboxes.

To assign unique IDs you could add $index as in
id="inputCheckbox[{{$index}}]"

and for the label
for="inputCheckbox[{{$index}}]"

2 Likes

Thanks Ben I tested it but it still does not do it as intended.
I have a concern about {$index} here is my structure. Can the chechbox input have an index?
image

You should not be naming your checkboxes like that.

Use the same name for your checkboxes, followed by [] so

name="inputCheckbox[]"

For checkbox id use

dmx-bind:id="'checkbox' + $index"

For the for attribute of your checkbox use

dmx-bind:for="'checkbox' + $index"

also it’s better to post your code here instead of screenshot, as we can’t copy/paste from your screenshots.

1 Like

Thanks!!

Just out of curiosity, can this id be written in the properties here?
image

No, this is for static ID only. You need to have dynamic ids as you are using your checkboxes in a repeat.

1 Like