Hide text if its dataset content is empty

I want to hide and show some text elements referenced to a dataset, if the content of this dataset is empty.
Can anyone help me?

Hi,
You can use getTotalCount to get the number of items from the dataset, if it equals to 0 you can show and hide the text elements you want.

Good luck :slight_smile:

But how I could know if the text box is empty??
Like:

let text199 = $w(’ #text199 ');

if(text199.value === ’ ‘){
$w(’ #text199 ‘).hide();
$w(’ #box1 ').hide();
}

→ In the #text199 field I have asigned a cell of the database, and in some cases this cell doesn’t contain information, so I want to hide/collapse this text field. The same happends with other text fields so I would
want to know individually wich ones are empty and wich ones no.

Could you help me?

Thanks for the replay.

You can use query to get the data from your database, check it out here .
Your code should look like this for example:

import wixData from 'wix-data';

// ...

wixData.query("myCollection")
  .eq("title", "Dr.")
  .find()
  .then( (results) => {
    let text199 = results.items[0].text199; //the name of the field
    if(text199 === ""){
        $w('#box1').hide();
    }
  } )
  .catch( (err) => {
    let errorMsg = err;
  } );