Hello you guys, I’m completely new to wix code and I have been trying to figure something out for the last two hours.
I have a Text Input called input1. Now I have created a button = button3. On click this button I want it to check the string value of input1 is equal to for instance ‘a’ and if that is the case redirect the visitor to the location /1.
Here is my code for now. I want to add several links according to the answer in Input1
import wixLocation from ‘wix-location’;
export function button3_click(event, $w) {
var pass= $w(‘#input1’)
if (pass===‘a’) { wixLocation.to(‘/1’);
} }
I also tried this code:
import wixLocation from ‘wix-location’;
export function button3_click(event, $w) {
var pass= $w(’ #input1 ‘)
var a = ‘one’
var b = ‘two’
if (pass===‘a’) { wixLocation.to (’/1’); }
else if (pass===‘b’){ wixLocation.to (‘/2’); } }
This code offcourse works:
export function button4_click(event, $w) {
wixLocation.to(‘/1’)
}
Thanks in advance,
I’ll keep trying.