Help please - class toggle within a repeat

I have a form where I want the class of an icon to toggle based on the value one of the inputs. The difficulty is that it is a multi-item form generated within a repeat. As such the names/ids are set dynamically. Normally, I would just set the class to toggle on input.value however I can’t see any way of using the $index in the toggle expression as it would effectively have to parse the $index and then parse again as a string with the value of $index.

The ids are set like

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

while the names are set like

dmx-bind:name="'item['+$index+'][property1]'"

What I want to do is something like

dmx-class:text-success="'inp_item'+$index'.value'"

but I just can’t seem to work out how to do it…

Can any of you heroes help?

What if you also use a static name for your input and use it in the dynamic class expression?

Thanks @Teodor
So set both a static and dynamic name for the same input?

Yes

I may have done something wrong but I still can’t get it going

This is the button that I want the class to change for:

<button dmx-bind:id="'authbtndrive'+$index" class="btn" dmx-class:text-success="authdrive.value" dmx-class:text-secondary="!authdrive.value">

This is the input:

<input dmx-bind:id="'authdrive'+$index" id="authdrive" name="authdrive" dmx-bind:name="'auth['+$index+'][authdrive]'" type="hidden" class="form-control" dmx-bind:value="teamsheetdrive">

both are within a repeat.

I’ve tried static name, static id and both static

Basically I want to click the button to toggle the success/secondary classes while also toggling between 1 (success) & 0 (secondary) in the corresponding value on that line of the repeat

I am not sure I understand this. Do you just want to toggle the button class on clicking the button itself?

Thanks for the help @Teodor
The field value is set originally by a SC but toggled by clicking the button. I want the class of the button to correspond to the value of the field - so essentially toggled but I don’t know the starting point of the field value (0 or 1).

Hi @teodor,
I think I got it working. It looks like the static ID must be before the dynamic one in the element.