Placeholder for Search Results

Hello,

I have a search bar which allows a user to search a database and find relevant store locations which are nearest to them, depending on the suburb which they have entered in the search bar. The results are displayed on a new page via a repeater. At the top of the results page, I would like to have a sentence which says “Showing results for stores near (user input suburb)”

I haven’t been able to attain the correct code to allow such a sentence: the following is the code which I currently have, but the placeholder code (line 7 of ‘Results Page’) keeps returning an error saying that ’ The placeholder parameter that is passed to the placeholder method cannot be set to the value . It must be of type string.’

Search Page:

import {local} from 'wix-storage';
import wixLocation from 'wix-location';

$w.onReady(function () {
});

export function StoreSearchButton_click() {
 let word = $w("#StoreSearchBar").value;
 local.setItem("SuburbSearch", word);
 wixLocation.to(`/copy-2-of-play`);
}

Results Page:

import {local} from 'wix-storage';
import wixData from 'wix-data';

$w.onReady(function () {
 var sameWord = local.getItem("searchWord");
 $w("#StoreSearchBar").value = sameWord;
 $w("#StoreSearchBar").placeholder = sameWord;
 $w('#dataset1').onReady(function () {
 search();
 });
});

export function searchButton_click() {
 search();
}

function search() {
 wixData.query('Stores')
 .contains('storeAddress', $w("#StoreSearchBar").value)
 .find()
 .then(res => {
 $w('#repeater1').data = res.items;
 });
}

Any assistance or suggestions would be greatly appreciated.

Thank-you

You are saving the value to storage using the keyword SuburbSearch :

local.setItem("SuburbSearch",word);

And you then when you attempt to get the value, you use the keyword searchWord.

var sameWord = local.getItem("searchWord");

You need to use the same keyword for both the setItem and getItem functions.

Thank-you very much, that was the exact solution that I was looking for - this forum is very helpful and the Velo team do a wonderful job.