首页 > 解决方案 > Radio button on Wix dynamic page

问题描述

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

标签: javascriptradio-buttonvelodynamic-pages

解决方案


您可以使用 if/else 语句使用selectedIndex函数更改单选按钮组的选定值。将代码放在页面的onReady()函数下,并使用Wix Location 的 Path函数检查您所在的页面。


推荐阅读