Pass string to text element after data query


I’m sure there has to be a super-easy way to do this. I have the “style” field key and the “details” field key populating dropdown menus and removing the duplicates in the process. I need to pass the first item string from the “fit” and “material” field keys to separate text elements after dropdown values have been selected. This is all I have so far:

function DetailsDescription() {
    wixData.query("options")
        .contains("details", $w("#detailsdropdown").value)
        .find()
        .then(results => {

I know it ends with this:

$w("#fittext").text = ???
$w("#materialtext").text = ???

Try this →

 wixData.query("Options")
        .contains("details", $w("#detailsdropdown").value)
        .find()
        .then((results) => {
          $w("#fittext").text = results.items[0].fit;
          $w("#materialtext").text = results.items[0].material;
         });

Attention Ajit, i don’t belive that this will work, since the ID of the selected Database/Data-Collection is Case-Sensitive (i think).

wixData.query("options") ---> will this work? I do not know.
wixData.query("Options") <--- try it out
import wixData from 'wix-data';

$w.onReady(function () {
    wixData.query("myData")
    .find()
    .then( (results) => {
 if(results.items.length > 0) {
 let myFirstItem = results.items[0];
 let myLastItem = results.items[results.items.length];
        console.log("My first item = " + myFirstItem)
        console.log("My last item = " + myLastItem)

        $w("#fittext").text = myFirstItem.fit;
        $w("#materialtext").text =myFirstItem.material;

        } else {
 // handle case where no matching items found
        }
    } )
    .catch( (err) => {
 let errorMsg = err;
    } );
})

@russian-dima Yes Surely Friend !!
It was a long time !!
Hope you are fine !!

I concentrated on the id of the database in his code only !!!
I have updated my code above also !!

Thanks !!

@ajithkrr
Hello i am back again :grin:. Yes i am fine thanks.
I saw you improved your coding skills a lot! Keep going like that.
Perhaps i will soon learn from you, who knows :wink:.

That did the trick… Thank you guys very much!