Storage plz code and search in Database

Hello Guys,

I am new here and I have a Problem with my page.

My Goal is that the entered plz code of the user is stored locally, so we can do the search for the shops in our Database, without entering the plz code again.

Step “Search in Database”
import wixData from “wix-data”

export function ipostakodu_keyPress(event, $w) {
filter($w(“#ipostakodu”).value);
}
function filter(postakodu) {
$w(“#dataset1”).setFilter(wixData.filter().contains(“plz”, postakodu));
}

Step “Storage PLZ Code”
import { local } from ‘wix-storage’;

local.setItem(“#ipostakodu”);

let value = local.getItem(“#ipostakodu”); // “value”

Hope you can help me.

Best Regards from Germany

David

Your imports should all be at the top together, followed by a onReady function for the page.
https://www.wix.com/corvid/reference/$w.html#onReady

As for Wix Storage, see the Wix API reference for how to use it.
https://www.wix.com/corvid/reference/wix-storage.Storage.html

With the code, you need to have the users search user input saved into Wix Storage first using the setItem function, then you need to run the setFilter on the appropriate dataset with the value in storage by calling it through the getItem function.

Hi @givemeawhisky ,

thanks for your respond.
I tried my best, but I didn’t get the results. And I don’t know how I can check it.

Can anyone check my code, please?

Code Page 1:

Code Page 2:

Best Regards from Germany
David

Hello David.
In you first screenshot you are using .text attribute on TextInput, it should be .value.