$w.onReady( function () {
$w( ‘#BackgroundSwatches’ ).onChange(() => {
let selectedIndex =$w( ‘#BackgroundSwatches’ ).selectedIndex
$w( '#dataset3' ).getItems(selectedIndex, 1 )
.then((result) => {
let items = result.items;
let totalCount = result.totalCount;
let offset = result.offset;
//here your code what should now happen with your image
$w( '#BackgroundSwatchImage' ).src = items.img //img=the reference-id of your column where you store all your images
})
. **catch** ((err) => {
let errMsg = err.message;
let errCode = err.code;
});
})
})
Above is my code. I am not sure where the problem is. But the image that is meant to change disappears and I get the error message below.
Wix code SDK Warning: The src parameter of “BackgroundSwatchImage” that is passed to the src method cannot be set to null or undefined.
This error is occurring on line 17 which is the line of code shown below-
$w( ‘#BackgroundSwatchImage’ ).src = items.img
I hope this helps.