# How do I make radio button instances dynamically?

**URL:** <https://forum.inductiveautomation.com/t/how-do-i-make-radio-button-instances-dynamically/87000>\
**Category:** Ignition\
**Tags:** ignition81, perspective\
**Created:** [March 8, 2024, 1:23am UTC](https://forum.inductiveautomation.com/t/how-do-i-make-radio-button-instances-dynamically/87000 "2024-03-08T01:23:05Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jose\_Rodolfo\_Mutuc](https://avatars.discourse-cdn.com/v4/letter/j/e0b2c6/32.png) [@Jose\_Rodolfo\_Mutuc](https://forum.inductiveautomation.com/u/Jose_Rodolfo_Mutuc)\
**Post date:** [March 8, 2024, 1:23am UTC](https://forum.inductiveautomation.com/t/how-do-i-make-radio-button-instances-dynamically/87000/1 "2024-03-08T01:23:05Z")

</div>

in the image below i want to create a parameter for instance instance number . when i input 3 the radios instance will be 3.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/c/1c5729b23ae11dc91436ac854ae9faaf92a449a1.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/c/5c6352ce30dcd79ccbfee618e254ed50208614ca.png)

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [March 8, 2024, 1:45am UTC](https://forum.inductiveautomation.com/t/how-do-i-make-radio-button-instances-dynamically/87000/2 "2024-03-08T01:45:26Z")

</div>

You need to have a binding on the instances property of the radio button component with a script transform. The expression part of the binding should point to the value that you will use to determine the number of radio buttons to have.

The script transform would contain a script that would create the number of instances specified with the required details, something along the lines of:

```auto
radios = [
	{
		"text": "Option %d" % (idx + 1),
		"selected": False,
		"value": idx
	}
	for idx in xrange(value)
]

radios[0]['selected'] = True
return radios

```

---

<div class="post-metadata">

**Author:** ![Jose\_Rodolfo\_Mutuc](https://avatars.discourse-cdn.com/v4/letter/j/e0b2c6/32.png) [@Jose\_Rodolfo\_Mutuc](https://forum.inductiveautomation.com/u/Jose_Rodolfo_Mutuc)\
**Post date:** [March 8, 2024, 6:01am UTC](https://forum.inductiveautomation.com/t/how-do-i-make-radio-button-instances-dynamically/87000/3 "2024-03-08T06:01:34Z")

</div>

thank you i will try

---

<div class="post-metadata">

**Author:** ![Jose\_Rodolfo\_Mutuc](https://avatars.discourse-cdn.com/v4/letter/j/e0b2c6/32.png) [@Jose\_Rodolfo\_Mutuc](https://forum.inductiveautomation.com/u/Jose_Rodolfo_Mutuc)\
**Post date:** [March 8, 2024, 6:10am UTC](https://forum.inductiveautomation.com/t/how-do-i-make-radio-button-instances-dynamically/87000/4 "2024-03-08T06:10:14Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/0/60d46b4d184bb999eeecbd97a9fa007969a9645c.png)  
It work but how to modify the names of the radios?

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [March 8, 2024, 7:39am UTC](https://forum.inductiveautomation.com/t/how-do-i-make-radio-button-instances-dynamically/87000/5 "2024-03-08T07:39:36Z")

</div>

you should use this

> **[Perspective - Flex Repeater | Ignition User Manual](https://docs.inductiveautomation.com/docs/8.1/appendix/components/perspective-components/perspective-embedding-palette/perspective-flex-repeater)**
>
> The Flex Repeater component lets you easily create multiple instances of views for display in another view.

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [March 8, 2024, 8:00am UTC](https://forum.inductiveautomation.com/t/how-do-i-make-radio-button-instances-dynamically/87000/6 "2024-03-08T08:00:33Z")

</div>

See the part of the code that says `"text": "Option %d" % (idx + 1),` ?  
That's where the name is set. There are numerous ways of doing this, which one to use depends on how the names of your radios are chosen (and what you're trying to do)

If it's a fix list, you could do something like this:

```python
options_names = ["foo", "bar", "pox", "wuz"]
radios = [
	{
		"text": name,
		"selected": False,
		"value": idx
	}
	for idx, name in enumerate(options_names[:value])
]

```

Note that this will limit the number of radios to the number of names in `options_names`.  
There are ways around this, but whether they should be used depends, again, on what you're trying to do.
