0

I am currently working on a dynamic page setup on my site which involves radio buttons. There are 4 radio buttons with each one linking to a different dynamic page and I have added the below code to change the url to match the relevant selection

export function radioGroup1_change() {
 

 
 const label = $w('#radioGroup1').value
 let url = wixLocation.to(`/dynamic-page/${label}`);
 
    }

(Nearly) everything works fine - the pages change according to the selection made in the radio buttons and the url follows suit. However, the page is set up to load onto 'Page 1' of the dynamic page and on loading the radio button for Page 1 is highlighted to indicate we are on that page. When i click on 'Page 2' (as an example) on the radio buttons, everything changes correctly but the radio button reverts to highlighting 'Page 1' instead of staying highlighted on 'Page 2'.

Is there something missing from this code which I need to add to correct this please as I have scoured this forum but not been able to find any answers unfortunately?

Thanks

The_Train
  • 319
  • 3
  • 11

1 Answers1

0

You can use a if/else statement to change the selected value of the Radio Button Group using the selectedIndex function. Put the code under the page's onReady() function and use Wix Location's Path function to check which page you are on.

Shan
  • 948
  • 1
  • 9
  • 17
  • Ok, but why is that happening? It worked fine before I added the above export function - surely radio buttons are designed to be highlighted by the little checkbox next to the value when selected – The_Train Apr 10 '21 at 17:48