Sorry my bad, i do not know why i forgot to copy&paste the first two lines.
Look here…
import wixData from 'wix-data';
var myResults
$w.onReady(function () {
wixData.query("Materials").find()
.then( (results) => {
if(results.items.length > 0) {
myResults = results.items
} else {
// handle case where no matching items found
}
} )
.catch( (err) => {
let errorMsg = err;
} );
$w('#dropdown1').onChange(()=>{
$w('#image1').src=myResults[$w('#dropdown1').selectedIndex].image
})
});
Now your code should work again.
“myResults” was red marked because this variable was used but not defined!
And always when you work with DATA you need first to import…
import wixData from ‘wix-data’;
Good luck & happy coding.