[SOLVED] How to target a static component using a dynamic value to change the components properties

I have components named “label_One”, "input_One, “label_Two”, “input_Two”, “label_Three”, “input_Three”.

I have a list of sublists that would look like:
[
[One, 1],
[Two, 2],
[Three, 3]
]

I want to setup a for loop that will take the first entry of my sublist “One”, “Two”, “Three” and change the properties on my components by targeting them dynamically in the for loop:

for j in List
set (“label_” + j.0)'s Text to “j.0”
set(“input_” + j.0)'s Text to “j.1”

Is this possible, can it be done?

Hello @marion.dorsett Welcome to the community
Could you please share the blocks you have used so far?

Be sure to check out our posts about How to ask Great Questions v2.0 and our Community Guidelines as you get started.

Thanks for the reply, but I actually just figured it out.

The key was the Any Component block, my guess would be that I misunderstood the documentation.

I have 30 sets of 3 fields that will create a list of data:

… and I didn’t want to have to link to each one individually, and using a loop makes the code faster, and easier to manage.

Using the Any Component block I was able to make the text string in the loop to target the component name like I wanted.

Now that I’ve figured this out, I save the data back to local storage by writing a function to extract the data from the fields, and not have to write static code for each component.

1 Like