javascript - 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
解决方案
您可以使用 if/else 语句使用selectedIndex函数更改单选按钮组的选定值。将代码放在页面的onReady()函数下,并使用Wix Location 的 Path函数检查您所在的页面。
推荐阅读
- apache - 如何在不使用 Windows 服务的情况下从 DOS 启动 Apache
- r - 将重复数据从长转换为宽,同时在 R 中保留键值对
- spring-boot - 从 Maven 依赖项调用 REST 控制器
- rabbitmq - 如何启动生产rabbitmq服务器
- java - 无法从在 azure vm 上运行的 java 连接到 azure postgres db
- javascript - 原生应用在 Chrome 网络请求中充当代理
- docker - 如何在 ECS 中托管 Artifactory
- python-3.x - Django:models.py 中的类不会导入
- delphi - QuickLogger 最佳存储解决方案,无需额外安装
- gcc - 是否存在用于 x86 指令的 GCC 内置函数的文档?