Vorbly <Code>
CODING MADE EASY WITH VORBLY
WIX CODE CHANGE BUTTON LINK (WEB URL)
Need to change button links for different scenarios? This tutorial will show you how to change button links for different scenarios using Wix Code. You will be able to direct visitors to different webpages based on their user input. We will provide you with the webpage elements and sample codes required to implement this feature.
THE DEMO
THE ELEMENTS
The Page
User Input: #dropdown1
Button Element: #LearnMore
External URLs:
-
website1: <insert URL1>
-
website2: <insert URL1>
THE CODE
Page Code
import wixLocation from "wix-location";
export function LearnMore_click(event, $w) {
let option = $w("#dropdown1").value;
if ( option === "website1" ) {
wixLocation.to("<insert URL1>");
} else {
wixLocation.to("<insert URL2>");
}
}
COMMENTS
I'm a paragraph. Click here to add your own text and edit me. It's easy.