Dynamic Page collapse and show images

Hello,

I am trying to create a dynamic page where image boxes will either display an image pulled in from the database list I have created, or collapse if there is nothing in the cell.

I have tried using this sample code and replacing the dataset and video parts with no luck: https://www.wix.com/code/home/forum/community-discussion/how-to-hide-an-element-within-my-dynamic-page

Thank you in advanced.

Hi Craig ,

Could you please show what comes up when you tried that?

Here’s what I’m using right now. I’ve do have little knowledge of coding and therefore it’s probably a simple mistake I’ve made.

Additionally i get no error messages when I preview the page. The image I am trying to expand is collapsed on page load and when I use this code the image don’t expand at all.

One thing you missed. Field key only contains small letter, so the key of Image should be image.

if ($w("dynamicDataset").getCurrentItem().image){ // image instead of Image

hope this helps!
Best,

Mustafa

Thanks for helping with this. I’ve updated that with image instead of Image however, the image remains collapsed when I preview the page. Not too sure where to go from here.

@craigharbour could you please sent me the link of your website

@mhammouz The site isn’t live yet. Might that be the problem?

no, its ok

@mhammouz https://www.checkpointplanet.com/ Here is the site URL however, the dynamic page in question hasn’t been published yet.

@craigharbour , The problem caused by the field name, which is image1 instead of image
as it shows in your dataset.

@mhammouz That’s worked perfectly, thank you so much. I knew it was a silly little mistake.