Collapse/Expand elements in a dynamic page if a field in a database is empty

Hello,
So i have multiple music albums in my dataset, some albums have 9 tracks, and some 21 tracks, here is what I did and it is working great:

$w.onReady(() => {
$w(“#dynamicDataset”).onReady(() => {
let item = $w(“#dynamicDataset”).getCurrentItem();
if (!item.track10Name) {
$w(“#audioPlayer10”).collapse();
$w(“#audioPlayer11”).collapse();
$w(“#audioPlayer12”).collapse();
$w(“#audioPlayer13”).collapse();
$w(“#audioPlayer14”).collapse();
$w(“#audioPlayer15”).collapse();
$w(“#audioPlayer16”).collapse();
$w(“#audioPlayer17”).collapse();
$w(“#audioPlayer18”).collapse();
$w(“#audioPlayer19”).collapse();
$w(“#audioPlayer20”).collapse();
$w(“#audioPlayer21”).collapse();
}
});

Please be aware that this does not work with a repeater as far as I know.

#dynamicDataset - is the data access on my title page generated by the content manager
track10Name in the if statement after the !item. is the text field key in the date base
#audioPlayer10 is the audio player name on the title page

So basically, what this code does, any player on the title page that has a blank track name on the content collection database collapses.

The reason I wanted it to collapse is to make the players disappear and also the Strip pull up.

The reason I have ordered to collapse all the other players after it is because one of the albums has 21 tracks. (So basically when you create new content table, you need to create columns based on the maximum number of tracks your albums have in a database)

The reason I just stated in the if statement track10Name alone is that by logic any album that doesn’t have track 10 will not have another tracks after it.

Hope this helps.