How to hide an element within my Dynamic Page?

Is their a way to hide an element automatically when there is no information what so never within the cell form a collection(an blank cell)? If so how can this be done?

I’m try to hide a youtube video element because their are some cases where they is no YouTube URL to change the video, if possible I like to subsatue the blank video for an image.

if value = ture.show
or
if value === 0.hide button (something like this?)
I hope this makes sense?

I’d do the following:

  1. Set the video element to be hidden or even collapsed on load via the Property panel .

  2. When the page loads and the dataset ready check if the field has a value. In the case the value exists, show the element.
    Here is a sample code you can adapt by changing the IDs of your dataset, video field, and video element.

$w.onReady(function () {
	$w("#dataset1").onReady(()=>{
		if($w("#dataset1").getCurrentItem().videoField){
			$w("#myVideoElement").show();
		}
	});
});
1 Like

Thanks for your helped!

I am trying to do the same thing but having trouble getting the code to work. I have all of the elements in a box and I do not want to show a box until data is entered into the dataset. When I put in my dataset it says my dataset is not a valid selector name.

Hi, just wondering if you might have the same example for an image rather than a video?

Thanks

Has anyone gotten this code to work? I am trying to hide an image. so when i use the suggested code above with my info subbed in it just hides all images instead of the ones that contain not value/info in the field.

Hello Marketing-King xD,

well first at all, do NOT reopen old posts. Do better open your own one with your own issue/problem. You can link to this page in your post than.

Back to your issue: Of course this CODE will close all of your images. You have to modify your CODE to get it to work like you want.

You have to generate an “if-querry” to compare the values.

currentItem = $w("#YourDataSet").getCurrentItem().YourCoulmnIDhere

if(currentItem==="YOUR IF-QUERY/COMPARISSON here") {"IF YES"}
else {"IF NO"}

And also note, that this will work just on a dynamic-page with a dynamic-dataset.

1 Like

@foogic55421 Thanks for helping out!