HSLBX15 Posted October 7, 2011 Report Share Posted October 7, 2011 Hi all, I'm trying to hide a field if there if no data is returned in the search results. For clarification it's a Details Datapage. I'm pretty sure this is really really simple for someone who knows javascript but I can't seem to piece together enough info from the other posts or the web to get it right. This is what I have so far: if("[@field:Address]"== ""); { document.getElementById("[@field:Address]").style.display = "none"; } Also, it's in an html block at the bottom of the datapage elements list. Any help would be most appreciated! Quote Link to comment Share on other sites More sharing options...
Aariel Posted October 7, 2011 Report Share Posted October 7, 2011 hi, there is a forum post discussing this problem: viewtopic.php?f=3&t=12266&p=14194&hilit=hide#p14194 I guess it can be something as follows: var v= document.getElementById('EditRecordAddress').value; if (v = "") { document.getElementById('EditRecordAddress').style.display = "none"; } Quote Link to comment Share on other sites More sharing options...
HSLBX15 Posted October 7, 2011 Author Report Share Posted October 7, 2011 Thanks for that - I hadn't seen that post. But unfortunately it still doesn't work. Below are 3 of the similar versions I've tried. Does it have to do with where I've located the html box? Or do I need to delete the original address field element? var v= document.getElementById("[@EditRecordAddress]").value; if (v = "") { document.getElementById("[@EditRecordAddress]".style.display = "none"; } var v= document.getElementById('EditRecordAddress').value; if (v = "") { document.getElementById('EditRecordAddress').style.display = "none"; } var v= document.getElementById("[@EditRecordfield:Address]").value; if (v = "") { document.getElementById("[@EditRecordfield:Address]".style.display = "none"; } Many thanks Quote Link to comment Share on other sites More sharing options...
HSLBX15 Posted October 7, 2011 Author Report Share Posted October 7, 2011 I've now tried deleting the original address field, fixing the parenthesis in the last example, and moving it to a footer and none of those seem to work. (the later two were tried together). Thanks, Quote Link to comment Share on other sites More sharing options...
anibaldps Posted October 11, 2011 Report Share Posted October 11, 2011 Hi! Try them with double cuotes: <script type= "text/javascript"> var v= document.getElementById("EditRecordAddress").value; if (v == "") { document.getElementById("EditRecordAddress").style.display = "none"; } </script> Quote Link to comment Share on other sites More sharing options...
bahar_vm Posted October 13, 2011 Report Share Posted October 13, 2011 Two equal signs is the correct one. (==) Also note that it works if your field is in the details page or an update form and it is editable. If the field is Display Only this code does not work. By the way, Caspio's next version which is scheduled to be released by the end of October has a built-in feature to hide the field on details and results page if the value is blank. So no Java Scripting will be needed. Best, Bahar M. Quote Link to comment Share on other sites More sharing options...
HSLBX15 Posted October 13, 2011 Author Report Share Posted October 13, 2011 Great thanks very much for all your help. I've also found a less sophisticated way of accomplishing the same end with html and the field codes. But I will try these tips and I look forward to the new release in October. Quote Link to comment Share on other sites More sharing options...
cheonsa Posted January 10, 2019 Report Share Posted January 10, 2019 Hi all, Hiding fields if empty doesn't need to have custom coding. This can be done using the standard feature of Caspio. On your DataPage > Configure Details Page Fields > Advanced enable "Hide fields if blank". Please refer to the screenshot below: Regards, kristina Quote Link to comment Share on other sites More sharing options...
Kurumi Posted March 18, 2019 Report Share Posted March 18, 2019 You can also try using CSS on hiding: <style> input[name="Field_Name"] { display: none !important; } </style> Quote Link to comment Share on other sites More sharing options...
astroboy Posted December 13, 2020 Report Share Posted December 13, 2020 Just to add on this, if you don't have any conditions in hiding a field, you may use HTML and CSS code to do this. Here's a HowTo article that you may check for reference: https://howto.caspio.com/tech-tips-and-articles/common-customizations/how-to-hide-fields-in-datapages/ Quote Link to comment Share on other sites More sharing options...
astroboy Posted December 13, 2020 Report Share Posted December 13, 2020 However, if you are working on a tabular DataPage, you will need to use a slightly different code. Luckily, there's a forum post regarding this that you may check. Here's the link: 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.