noscamiam Posted September 14, 2010 Report Share Posted September 14, 2010 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! Quote Link to comment Share on other sites More sharing options...
Barbara Posted September 15, 2010 Report Share Posted September 15, 2010 Take a look at the script "show/hide a link on result" at viewtopic.php?f=14&t=12278. It has pretty much the same logic. Cheers, Barbara Quote Link to comment Share on other sites More sharing options...
noscamiam Posted September 15, 2010 Author Report Share Posted September 15, 2010 I actually used the code from your suggested link to the create the first part of the IF statement. My problem is still figuring out the correct format for the display none part of the statement. Quote Link to comment Share on other sites More sharing options...
cheonsa Posted January 3, 2019 Report Share Posted January 3, 2019 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. Regards, kristina Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.