Set radio button's selected value programmatically

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.]

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

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

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

Thanks dear.. You indeed helped me