Jump to content

Remove an empty field using javascript


Recommended Posts

I am trying to remove a field from a details page when the field is empty. I have read several posts seeking similar funtionality but I still have not learned the secret javascript handshake on how to make this work. My understanding is that style.display for a field that is set to "none" means the field will no longer take up space on the details page as opposed to only being hidden. Here is what I have:

/* See if Comments1 field contains a value*/

var com1 = '[@field:Comments1]';

if (com1 == '')

{

"Insert javascript code here to set display of Comments1 field to none"

}

I know the if() part of the above statement works because I can display a link when the field is empty (which I did for testing that part of the code). However substituting in code to set the field display to "none" has not been successful. Here is what I have tried so far...

1) document.getElementById("EditRecordComments1").style.display="none";

2) document.getElementById(\"EditRecordComments1\").style.display=\"none\";

3) document.getElementById("[@EditRecordComments1]").style.display="none";

4) document.getElementById("Comments1").style.display = "none";

I read one post that indicated an event (like onload) is needed to trigger javascript code but that didn't seem to be the case since my test code to make a link appear worked fine without referencing any specific event in the javascript. Also, if I am off-base on "none" preventing the affected field from even taking up space on the html details page, please let me know.

Thank you!

Link to comment
Share on other sites

  • 8 years later...

Hi,

 

Hiding a field from the details page when the field is empty is now a standard feature of Caspio. You just need to edit your DataPage > Configure Details Page Fields and go to Advanced tab.  Check the textbox for "Hide field if Blank". Please see screenshot below. 

image.png.79590481b6c3b1a6d58cf9d9520ad918.png

 

Regards,

kristina

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...