So I have this displayed tags which is connected to my database via code, some of my items have the tags while some others doesn't. If the item have the tags, it'll work fine, but if the item doesn't have the tags, it'll show the text which i don't want to be shown. How can i hide the unwanted tags (shown in red arrow) if the item doesn't have the tags? here's my code.
PS: the text box which i used for the tags is #text58
$w.onReady(function () {
$w("#dataset1").onReady(function () {
$w("#repeater1").onItemReady(($item, itemData) => {
let tags = itemData.promo;
let tagsHtml = tags.map(tag =>
`<span style="background: #f44336;
border-radius: 5px;
line-height: 2.6;
padding-top: 5px;
padding-bottom: 5px;
padding-left: 5px;
padding-right: 5px;
margin-left: 0px;
margin-right: 0px;
text-align: center;
color: #ffffff;
font-weight:900;
font-size: 12px">${tag}</span>`)
.join(' ');
$item('#text58').html = tagsHtml;
});
});
});
Here's some screenshot of it
![](https://static.wixstatic.com/media/a27d24_96396441ccc44102a5e4e1f333d0c228~mv2.png/v1/fill/w_49,h_22,al_c,q_85,usm_0.66_1.00_0.01,blur_2,enc_auto/a27d24_96396441ccc44102a5e4e1f333d0c228~mv2.png)
![](https://static.wixstatic.com/media/a27d24_27bacf30747e4f72b9c81f875c407768~mv2.png/v1/fill/w_49,h_25,al_c,q_85,usm_0.66_1.00_0.01,blur_2,enc_auto/a27d24_27bacf30747e4f72b9c81f875c407768~mv2.png)
Here is what i use to hide/collapse information that comes from a data set but some items may not have them i want them hid,
// collapse code for Promo starts here $w.onReady(() => { $w("#dynamicDataset").onReady(() => { // Gets the current item properties and stores them in a variable called item const item = $w("#dynamicDataset").getCurrentItem(); // Checks if the current item has a value in the "Promo" field if (!item.promo) { // Collapses the image if there is no value for "Promo" field $w("#text58").collapse(); } }); }); // collapse code for Promo finishes here
Hope this helps