This is my first attempt to interact with users and query a database. I have tried numerous examples and have not had luck with any of them. I imported the collection. It needs to be read only. All I want to do is ask the user to enter their lake address and search the db for a match. Then display the results of the matching entries in a table. After that, I would like have the user choose their address from the matches (but I’m not to that point yet).
Here is the code:
import wixData from ‘wix-data’ ;
function resetForm() {
const inputList = $w( ‘#searchBox’ );
inputList.forEach(element => {
element.value = ‘’ ;
});
}
export function searchButton_click(event) {
wixData.query( “HLAGIS” )
.contains( “lakeAddress” ,$w( ‘#searchBox’ ).value)
.find()
.then(res => {
$w( “#table1” ).rows = res.items;
$w( “#table1” ).expand();
});
}
$w.onReady( function () {
// id is for code purposes; datapath is the collection field name; label is the column title;
$w( “#table1” ).columns = [{ “id” : “Col1” , “dataPath” : “lakeAddress” , “label” : “Lake Address” , “type” : “string” },
{ “id” : “Col2” , “dataPath” : “parcelNumber” , “lable” : “Parcel #” , “type” : “string” },
{ “id” : “Col3” , “datapath” : “name” , “lable” : “Name” , “type” : “string” },
{ “id” : “Col4” , “datapath” : “mailAddress” , “lable” : “Mail Address” , “type” : “string” },
{ “id” : “Col5” , “datapath” : “city” , “lable” : “city” , “type” : “string” },
{ “id” : “Col6” , “datapath” : “state” , “lable” : “state” , “type” : “string” },
{ “id” : “Col7” , “datapath” : “zip” , “lable” : “zip” , “type” : “string” }
];
})
The dataset is Read-only. Here is what the interaction preview looks like:
What am I doing wrong? Thank you in advance!