简体   繁体   English

Wix 动态页面上的单选按钮

[英]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有 4 个单选按钮,每个按钮都链接到不同的动态页面,我添加了以下代码来更改 url 以匹配相关选择

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. (几乎)一切正常——页面会根据单选按钮中的选择而变化,url 也会随之变化。 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.但是,该页面设置为加载到动态页面的“第 1 页”,并且在加载第 1 页的单选按钮时突出显示以指示我们在该页面上。 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'.当我单击单选按钮上的“第 2 页”(例如)时,一切都会正确更改,但单选按钮会恢复为突出显示“第 1 页”,而不是在“第 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谢谢

You can use a if/else statement to change the selected value of the Radio Button Group using the selectedIndex function.您可以使用 if/else 语句使用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.将代码放在页面的onReady() function 下,并使用Wix Location's Path function 来检查您所在的页面。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM