I am trying to create a search function on my website where a user inputs two values into two input boxes, and upon clicking the submit button, is forwarded to a specific link.
I can do this using the code below:
import wixLocation from'wix-location';
//put this code (below code) under the $w.onReady() function
$w('#goButton').onClick((event)=>{
if($w('#parentName').valid){
let parentName =$w('#parentName').value;
if($w('#dogType').valid){
let dogType =$w('#dogType').value;
wixLocation.to(`/${parentName}/${dogType}`);
}
});
What I am struggling with, however, is sending a user to:
wixLocation.to(`/${dogName}`)
based off:
wixLocation.to(`/${parentName}/${dogType}`)
What I am trying to do is send a user to one dynamic page with a URL ending (/dogName) from one data column of a collection based on the input of two other values from two other columns from the same collection (/parentName and /dogType). All three values would be on the same row of the collection.
For example, inputting Deneb and GoldenRetriever into the appropriate fields would forward a user to:
“website . com/dog/daisy”
How can I go about doing this? Any help, especially an example outline of code would be really appreciated.