@russian-dima good morning, I am trying to follow this but I am having issue. Can you assist?
I have the following:
import wixData from ‘wix-data’ ;
$w.onReady( function () { });
export function button5_click(event) {xxx()}
function xxx (parameter) {
wixData.query( “GCBalance” )
.eq( “cardNumber” ,$w( ‘#sGCNumber’ ).value)
.find()
.then( (results) => {
if (results.items.length > 0 ) {
let firstItem = results.items[ 0 ];
$w( '#resultsTable' ).rows = results.items
$w( '#cardOwner' ).text = firstItem.neuesFeld
$w( '#resultsTable' ).show();
} **else** {
// handle case where no matching items found
$w( ‘#sInvalid’ ).show();
}
} )
. catch ( (err) => {
let errorMsg = err;
$w( ‘#sInvalid’ ).show();
} );
}
Where “GCBalance” is my database collection, “cardNumber” is the title of the column on the collection, “#sGCNumber” is the input box.
“#resultsTable” is the table on the site page, and “#cardOwner” is the primary column on the collection.
I don’t want the table to display until after data is retrieved, so I had a “.show” function at the end, then two error message options should the database either encounter an error or not find the data entered.
This is my currently published page this is referenced on. Can you assist? I added a preset in the collection that is “1234567890” but no matter what I enter I get “Error: Invalid Card Number” (my #sInvalid response).
Appreciate any ideas!