Postal Code input redirect

I’m looking for the best way for a user to enter their postal code or city/state and be redirected to a page on my site that shows the offices in that area based on the criteria the entered. Thoughts?

You would have to have a dataset with Postal Codes and Offices available with respective URLs.

Then you need to query the input, find the Postal Code and if found, redirect to the page you want.

As soon as you have designed your Collection, everything will be easier.

Something like this:

import wixData from 'wix-data'
import wixLocation from 'wix-location'

$w.onReady(() => {
    let timeout
    $w('#inputPostalCode').onInput(({ target }) => {
        timeout = setTimeout(async () => {
            let query = await searchDataset(target.value)
            let result = query[0].title
            $w('#textResult').text = result
            $w('#textResult').onClick(() => {
        }, 500)

async function searchDataset(search) {
    let query = await wixData.query("postalCodes").hasSome("postalCodes", search).find()
    if (query.items.length > 0) return query.items