# Set radio button's selected value programmatically

**URL:** <https://forum.wixstudio.com/t/set-radio-buttons-selected-value-programmatically/69641>\
**Category:** Ask the community\
**Tags:** question, code, cms, wix\
**Created:** [March 16, 2025, 7:42am UTC](https://forum.wixstudio.com/t/set-radio-buttons-selected-value-programmatically/69641 "2025-03-16T07:42:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![\_Perera](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/_perera/32/102201_2.png) [@\_Perera](https://forum.wixstudio.com/u/_Perera)\
**Post date:** [March 16, 2025, 7:42am UTC](https://forum.wixstudio.com/t/set-radio-buttons-selected-value-programmatically/69641/1 "2025-03-16T07:42:03Z")

</div>

**Question:**  
[Clearly ask your question.]  
I have a radio button with 7 options in a cms form on home page  
I want to set its selected option based on which button is clicked on the same page  
these 7 buttons are on different places on the home page and I want to navigate to radio button and set its selected value based on that button click  
thanks  
wix editor

**Product:**  
[Which editor or feature is your question most relevant to? e.g. Wix Editor, Wix Studio Editor.]

**What are you trying to achieve:**  
[Explain the details of what you are trying to achieve. The more details you provide, the easier it is to understand what you need.]

**What have you already tried:**  
[Share resources, forum topics, articles, or tutorials you’ve already used to try and answer your question.]

**Additional information:**  
[Include any other pertinent details or information that might be helpful for people to know when trying to answer your question.]

---

<div class="post-metadata">

**Author:** ![DeanAyalon](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/deanayalon/32/94633_2.png) [@DeanAyalon](https://forum.wixstudio.com/u/DeanAyalon)\
**Post date:** [March 16, 2025, 2:28pm UTC](https://forum.wixstudio.com/t/set-radio-buttons-selected-value-programmatically/69641/2 "2025-03-16T14:28:11Z")

</div>

```js
const changeSelection = value => $w('#radio').value = value

$w('#choice1button').onClick(() => changeSelection('value1'))

```

A basic example:

- `changeSelection` is a function that takes a value and sets it within the radio button
- When the button is clicked, it fires the function with the value assigned to it

---

<div class="post-metadata">

**Author:** ![\_Perera](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/_perera/32/102201_2.png) [@\_Perera](https://forum.wixstudio.com/u/_Perera)\
**Post date:** [March 16, 2025, 5:22pm UTC](https://forum.wixstudio.com/t/set-radio-buttons-selected-value-programmatically/69641/3 "2025-03-16T17:22:32Z")

</div>

Thanks for your quick reply…  
By the way I’ve never done coding with Wix editor  
I’ll be grateful If you could explain how to do this  
meantime I’ll try to figure out how to do this  
Thanks

---

<div class="post-metadata">

**Author:** ![DeanAyalon](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/deanayalon/32/94633_2.png) [@DeanAyalon](https://forum.wixstudio.com/u/DeanAyalon)\
**Post date:** [March 16, 2025, 5:52pm UTC](https://forum.wixstudio.com/t/set-radio-buttons-selected-value-programmatically/69641/4 "2025-03-16T17:52:39Z")

</div>

If you’re using the legacy Wix Editor, you can enable “Dev Mode” through the toolbar on the top of the screen

If you’re using Wix Studio, the bottom-most icon on the left menu should allow you to enable code

---

<div class="post-metadata">

**Author:** ![\_Perera](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/_perera/32/102201_2.png) [@\_Perera](https://forum.wixstudio.com/u/_Perera)\
**Post date:** [March 17, 2025, 3:49am UTC](https://forum.wixstudio.com/t/set-radio-buttons-selected-value-programmatically/69641/5 "2025-03-17T03:49:16Z")

</div>

Thanks dear.. You indeed helped me
