Please help with code for loading dropdown results into gallery from media gallery field.

Hi all. I feel like I am so close, but I lack the understanding to complete. Please help out.
I currently have a dropdown connected via code (below), now I need to use the results of the dropdown to populate a gallery.
From the media gallery field not image field (see snap)
For reasons, it needs to be code, not through the editor.
$w.onReady( function () {

}); import wixData from ‘wix-data’ ;

//code for dropdown
export function dropdown1_change(event) {
wixData.query( “Property” )
.contains( “title” , $w( “#dropdown1” ).value)
.find()
.then(res => {
$w( “#gallery1” ).items = res.items; < is this part correct?
});
}
// code to load results into gallery??? < I need this part

I have looked at the Items and properties page for the gallery API, I can’t understand it.

This is literally the first and only piece of code I need for the site and seemingly a question that has come up a million times but with no definitive answer.

Please…please… some code for me to copy and paste. I know there will be 4974587 others who would benefit.
Or at least add an example to the tutorial you have here, but for galleries, not tables or [repeaters.](repeaters.
Velo Tutorial: Adding Collection Data Search Functionality | Help Center | Wix.com)
[Velo Tutorial: Adding Collection Data Search Functionality | Help Center | Wix.com](repeaters.
Velo Tutorial: Adding Collection Data Search Functionality | Help Center | Wix.com)

Note: I am not using a wix pro gallery.

Dropdown reads titles, error I think because i have no code and/or incorrect code to put results into gallery.

1 Like

Try this code

import wixData from'wix-data';
$w.onReady(function () {
});

exportfunction dropdown1_change(event) {    
   wixData.query("Property")
        .eq("title", $w("#dropdown1").value)        
       .find()
               .then((res)=> {
                     $w("#gallery1").items = res.items;                    
        });
   }

Same issue =( the images don’t change from the default, Thanks for replying though, I really do appreciate it.

Seriously, I have looked over 4 billion documents and examples, can I just pay someone for like 5 lines of code?

Within the Property Collection, what is the field name of the gallery?

gallery, same as snap shot. I’ve tried to keep it very simple… even then I cant quite get it >_<

@tsuyoidesigns ,gallery, same as snap shot. I’ve tried to keep it very simple… even then I cant quite get it >_<

Try this out, its a very simple fix but hopefully it helps:

import wixData from'wix-data';
$w.onReady(function () {
});

exportfunction dropdown1_change(event) {    
   wixData.query("Property")
        .eq("title", $w("#dropdown1").value)        
       .find()
               .then((res)=> {
                $w("#gallery1").src = res.items[0].title[0].mainMedia;                    
        });
   }