Hi ,
I am trying to work with a dataset but having no luck, I want to display values from a specific row of a database.
I have a database with 2 columns of data
A = number (I use this a row identifier)
B = Text A
C = Text B
On my page I would like two buttons to display the text from B and C clumns depending on the number entered in a text box .
I can capture the value from the input box but I do not know how to only display the text from the row required .
Can anyone point me in the right direction ?
Thanks
bob
Hello Bob,
A couple options you can do:
-
Filter the dataset to include the row you want, and connect the items via the interface ‘connect to database’
-
Using wix code you can use the .getItems(), to get the items of a specific row if you know the index of it, then to connect it to the button use . label.
It would look something like this:
$w("#myDataset").getItems(2, 1) //Here we get the item in index 2
.then( (result) => {
let items = result.items;
$w('#button').label - items[0].exampleField;
} )
.catch( (err) => {
let errMsg = err.message;
let errCode = err.code;
} );
Goodluck!
Majd