[solved]Gallery not showing image

I have a gallery connected to a dataset. I’m trying to change the images on the gallery using a dropdown menu. the problem is that I pass the src data of the selected item but the gallery doesn’t show the image. what am I doing wrong?

Update/solution:

after a lot of tries(and headaches) I found out the reason it was not showing the image, and was for two reasons:
1- I was missing the ’ =’ sign between " $w(‘#Gallery’).items " and " [{“src”:srx}] "
2- for some reason having connected the gallery to the dataset was a problem. so I created another gallery(mark to hidden on load) and connected that to the dataset to then extract the items data and pass it to my srx variable to use in the gallery for display. and it works!!

export function dropdown1_change(event, $w) {
 const dropselec = event.target.selectedIndex;
 let item = $w('#Gallery').items
 const srx = item[dropselec].src
 
    $w('#Gallery').items[{"src":srx}] 
        console.log(srx)
 
}

The object you pass to items should be of type ImageItem , not only the src.

hi Ohad, thanks for the answer, but I don’t know how to do that. can you please explain that to me?

Hi Fausto -

Maybe try the following code. Not tested. But this appears to be what Ohad may be referring to.

export function dropdown1_change(event, $w) {
const dropselec = event.target.selectedIndex;
let item = $w(’ #Gallery ').items;
const imgItem = item[dropselec];
$w(’ #Gallery ').items[imgItem];
console.log(imgItem.src);
}

Best,
Nick

thanks for the help Nick, but it does the same. the imgItem has all the data but the gallery doesn’t show the image.

Hey there
I tried this code for my similar problem and it got the opposite result i was looking for. It locks the dropdown menu and shows the menu choice based on what image you show in the gallery, as opposed to using the dropdown menu to select and display an image in the gallery.

Any ideas how to fix that?