wixdata.query display

New to WIX API here. I am trying to display a single field from my query as the initial value for an input box. Using the code below on a dropdown change event the results are not showing in the #input1. My question is this the best way of doing this, if so how do I pass a single result to an element?

let trl = $w(“#dropdown2”).value;
wixData.query(“TRAIL_COND”)
//.eq(“actv_ind”,“:true}”)
.eq(‘title’,trl)

.find()
.then( (results) => {
$w(‘#input1’).value = results.items.description;

} )
;

The query returns an array of results. Therefore, you need to get just one (the first) of them. Something like this:

let items = results.items;
let item = items[0];
$w('#input1').value = item.description;

I hope this helps.

Thank you Yisrael, that worked!!

1 Like