User input submit-links to designated page

What I need is a user input form that collects basic information (this part I have no issues with) but also a user entry box where they can be enter a serial number so that when the user hits submit it not only collects their basic information but sends them to a page specifically designated to the serial they input.

i imagine this would work with a simple if/then statement where “if user input = ’serial number’; then redirect to page designated to that specific serial number”

I have experience programming in python but not in this language. I was wondering if anyone has needed to do something similar or had any advice on how to get this accomplished?

Something like:

import wixLocation from 'wix-location'; //This line has to be at the top of the entire code
$w.onReady( function() {
$w("#submitButton").onClick( (event) => {
if($w("#input1").value === "Open Sesame") {
wixLocation.to("/myprivateplcae");//put here your wix page path or an external url
}
 })
})

If you want the redirection to take place only on submission successes, you can do it as well.

Thank you, this looks like it will be what I am needing. I will get a chance to mess around with it tomorrow. I do want the redirection to take place only on successes as well, so would I need an additional line for that?

@blackleafcollective if that’s what you want, then it shouldn’t be an onClick function.
I think the easiest way to do it is to use the “success” message that comes with the submit button:

import wixLocation from 'wix-location'; //This line has to be at the top of the entire code
$w.onReady( function() {
$w("#successMessage").onViewportEnter( (event) => {
if($w("#input1").value === "Open Sesame") {
wixLocation.to("/myprivateplcae");//put here your wix page path or an external url
}
 })
})

But might be tricky because clicking the submit button might clear the input field. I’m not sure if it happens before or after the success message (and I don’t have time to check).
So if it doesn’t work, you should save the info before:

import wixLocation from 'wix-location'; //This line has to be at the top of the entire code
$w.onReady( function() {
let secretPass;
$w("#input2").onBlur((event) => {
 secretPass= $w("#input2").value;
})
$w("#successMessage").onViewportEnter( (event) => {
if(secretPass === "Open Sesame") {
wixLocation.to("/myprivateplcae");//put here your wix page path or an external url
}
 })
})