# Hide Button on Dynamic Page When Field Is Empty

**URL:** <https://forum.wixstudio.com/t/hide-button-on-dynamic-page-when-field-is-empty/27740>\
**Category:** Ask the community\
**Tags:** code, question\
**Created:** [January 29, 2018, 4:51pm UTC](https://forum.wixstudio.com/t/hide-button-on-dynamic-page-when-field-is-empty/27740 "2018-01-29T16:51:57Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![\_brad](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/_brad/32/1488_2.png) [@\_brad](https://forum.wixstudio.com/u/_brad)\
**Post date:** [January 29, 2018, 4:51pm UTC](https://forum.wixstudio.com/t/hide-button-on-dynamic-page-when-field-is-empty/27740/1 "2018-01-29T16:51:57Z")

</div>

Say I have a dynamic page with a button that links to a website but then one of my rows doesn’t have a website so the column is blank. Can I make that button hidden when the field is blank but keep it shown when there is a link in the field?

Thanks!

---

<div class="post-metadata">

**Author:** ![ziv-shalev](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/ziv-shalev/32/669_2.png) [@ziv-shalev](https://forum.wixstudio.com/u/ziv-shalev)\
**Post date:** [January 29, 2018, 7:16pm UTC](https://forum.wixstudio.com/t/hide-button-on-dynamic-page-when-field-is-empty/27740/2 "2018-01-29T19:16:51Z")

</div>

sure,  
through some basic javascript code.  
just use the button’s hide() method in case the field is empty.

you can look for samples (in the resources section above) that show you how to select an element through code and then hide it.

good luck!

---

<div class="post-metadata">

**Author:** ![\_brad](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/_brad/32/1488_2.png) [@\_brad](https://forum.wixstudio.com/u/_brad)\
**Post date:** [January 29, 2018, 10:40pm UTC](https://forum.wixstudio.com/t/hide-button-on-dynamic-page-when-field-is-empty/27740/3 "2018-01-29T22:40:55Z")

</div>

I can show and hide stuff pretty well, but I’m not sure what the code is to know if the field is empty or not?  
Can you point out that example?

---

<div class="post-metadata">

**Author:** ![code-queen](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/code-queen/32/696_2.png) [@code-queen](https://forum.wixstudio.com/u/code-queen)\
**Post date:** [January 30, 2018, 5:47am UTC](https://forum.wixstudio.com/t/hide-button-on-dynamic-page-when-field-is-empty/27740/4 "2018-01-30T05:47:53Z")

</div>

Search for the word NULL here in the forum and/or the Wix API docs … that should lead you down the right path …

> **[Wix Editor Elements ($w) - Velo API Reference - Wix.com](https://www.wix.com/velo/reference/$w)**
>
> The $w namespace contains everything you need in order to work with your site's components.

---

<div class="post-metadata">

**Author:** ![derek38500](https://avatars.discourse-cdn.com/v4/letter/d/53a042/32.png) [@derek38500](https://forum.wixstudio.com/u/derek38500)\
**Post date:** [August 8, 2022, 8:05pm UTC](https://forum.wixstudio.com/t/hide-button-on-dynamic-page-when-field-is-empty/27740/5 "2022-08-08T20:05:47Z")

</div>

Hello,

I have been trying to do this same thing. I have been trying for weeks to get it to work, searching up and down the internet. I FINALLY GOT IT TO WORK!! Some Background: What I am doing is I have a job application form on our website that is write only, so someone can fill it out and apply. They can also upload their resume. THEN, I duplicated the entire form on a separate page and made it read only, so our HR department could read through applications on our site, instead of through the backend spreadsheet view.

what I was trying to do is make the “View Uploaded Resume” button disappear if they didn’t upload a resume. I have tested this code 6 ways to sunday on almost every browser and it works every time!

My dynamic dataset for this example is called “dynamicDataset”

```javascript
$w.onReady(function () {

    $w("#dynamicDataset").onReady(() => {
        
        $w("#dynamicDataset").getCurrentItem();

        if ($w('#button').link == '') {
            $w('#button').hide();
        }
                
    });

});

```

😁

---

<div class="post-metadata">

**Author:** ![Kenneth\_Herskind](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/kenneth_herskind/32/99925_2.png) [@Kenneth\_Herskind](https://forum.wixstudio.com/u/Kenneth_Herskind)\
**Post date:** [March 27, 2025, 12:23am UTC](https://forum.wixstudio.com/t/hide-button-on-dynamic-page-when-field-is-empty/27740/6 "2025-03-27T00:23:03Z")

</div>

Legend. Actually works!!! Tons of other misinformation and nonworking code out there, but this is the one. Thanks!! Lifesaver. This is a huge bug with Wix’s dynamic pages and something they really ought to fix, but in the meantime, great info! TY!

---

<div class="post-metadata">

**Author:** ![Kenneth\_Herskind](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/kenneth_herskind/32/99925_2.png) [@Kenneth\_Herskind](https://forum.wixstudio.com/u/Kenneth_Herskind)\
**Post date:** [March 27, 2025, 12:43am UTC](https://forum.wixstudio.com/t/hide-button-on-dynamic-page-when-field-is-empty/27740/7 "2025-03-27T00:43:12Z")

</div>

> [@derek38500](#):
>
> ```javascript
> $w.onReady(function () {
> 
> $w("#dynamicDataset").onReady(() => {
>         
> $w("#dynamicDataset").getCurrentItem();
> 
> if ($w('#button').link == '') {
> $w('#button').hide();
> }
>                 
> });
> 
> });
> 
> ```

BTW, noticed that this code only works for the buttons. If you have other elements, image for example, I found this code works better for images:

> [@How to hide a section on a dynamic item page when a specific CMS field is blank](https://forum.wixstudio.com/t/how-to-hide-a-section-on-a-dynamic-item-page-when-a-specific-cms-field-is-blank/60241/13):
>
> I use the below example all the time. Note the exclamation mark before currentItem, this means ‘if empty’. Replace: #yourDatasetID with the ID of your dynamic page dataset databaseFeildID with the field ID in the CMS you want to check #itemToHideID with ID of the page item you wish to hide const currentItem = $w('#yourDatasetID').getCurrentItem(); $w.onReady(function () { if (!currentItem.databaseFeildID) { $w("#itemToHideID").collapse(); } });

Replace:  
#yourDatasetID with the ID of your dynamic page dataset  
databaseFeildID with the field ID in the CMS you want to check  
#itemToHideID with ID of the page item you wish to hide

const currentItem = $w(‘#yourDatasetID’).getCurrentItem();

$w.onReady(function () {  
if (!currentItem.databaseFeildID) { $w(“#itemToHideID”).collapse(); }  
});

---

<div class="post-metadata">

**Author:** ![Kenneth\_Herskind](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/kenneth_herskind/32/99925_2.png) [@Kenneth\_Herskind](https://forum.wixstudio.com/u/Kenneth_Herskind)\
**Post date:** [March 27, 2025, 12:43am UTC](https://forum.wixstudio.com/t/hide-button-on-dynamic-page-when-field-is-empty/27740/8 "2025-03-27T00:43:58Z")

</div>

You can string both code elements together to hide buttons and images!
