I want to define 4 arrays with specific postal codes for each location, and then based on a postal code (value of a user-submitted form) I want to redirect user to a new location.
I have no idea what I am doing wrong (I am not a coder).
I am trying to do something like this, but it doesn't work:
<!DOCTYPE html>
<script>
function sprawdzKody() {
const mokotow = ["00-807", "00-808", "00-809"];
const ursynow = ["01-807", "01-808", "01-809"];
const targowek = ["02-807", "02-808", "02-809"];
const wesola = ["03-807", "03-808", "03-809"];
var kodPocztowy = document.getElementById("kodPocztowy").value;
if(mokotow.includes(kodPocztowy)){
window.location.href = "https://mokotow.geishasushi.pl";
}
else if(ursynow.includes(kodPocztowy)){
window.location.href = "https://ursynow.geishasushi.pl";
}
else if(targowek.includes(kodPocztowy)){
window.location.href = "https://targowek.geishasushi.pl";
}
else if(wesola.includes(kodPocztowy)){
window.location.href = "https://ursynow.geishasushi.pl";
}
else {
window.location.href = "http://geishasushi.pl/jestes-poza-rejonem";
}
}
</script>
<form onsubmit="return sprawdzKody();" class="kod-pocztowy">
<label for="kodPocztowy"> Kod Pocztowy</label><br>
<input type="text" id="kodPocztowy" name="kodPocztowy"><br>
<input type="submit" value="Znajdź Twoją restaurację">
</form>