Option for empty datafield

Hi. I was wondering if you could add an option to the dynamic page, so that if there is no data in the text box then the heading does not show. For example, I am doing a site about neighborhoods in NY. One of the categories is museums but not every neighborhood is going to have a museum, so I only want the title field to be populated if there is data in the relevant cell.

1 Like

You can collapse or hide a text element with some code.

$w.onReady(function () {
	$w("#myDataset").onReady(()=>{
		let itemObj = $w("#myDataset").getCurrentItem();
		if(!itemObj.museum){
			$w("#text1").collapse();
		}
	});
});

You can read more in Working in the Developer Tools Code Panel and in our API reference site.

Thank you. I’ll give that a go.