I had the idea to have a form that requires a specific answer, and when applied, will bring you to a specific page. I am very inexperienced with coding and was wondering if code was required for this effect or if it’s possible at all?
All what you will need…
- Inputfield
- if-else-statement
- wix-location-API
$w.onReady(()=>{
$w(‘#inputIDhere’).onChange(()=>{
let value=$w(‘#inputIDhere’).value
if(value=“word”){wixLocation.to(“”)}
else{console.log(“xxxxxxx”)}
});
});
Something like this you will need.
Just a simple 15sec.-example…
I did something similar, but used a table to drive the location. I had a user that needed to dynamically change the link, based on some input. I used a table with 2 fields, the first field held the answer to test for, and the second field was the link to the specific page. The end user was able to setup as many pages as they needed, and just put in a new code, and new link into the table, whenever they needed to add a new custom page. This avoided the user having to change any of the code behind the web page, and allowed the data to drive where to goto. All I would do, is use a query to test for the word, and if it was found, I fetched the link. I then used a variable to drive the link.
I also did this in a repeater and each of the containers in the repeater, got their own custom page. It worked slick.
let urllnk = $item ( “#textbuttonlink” ). text;
console . log ( "Url set to: " + urllnk );
// connect to custom page
wixLocation . to ( urllnk );