How can I prevent empty query values from creating empty table cells?
If you place the contents of a ColdFusion query in an HTML table, any blank query value may show up as an empty cell with no borders in the table. This is not a bug in ColdFusion, but rather a result of how the browser renders the a cell that looks like this:
To prevent this, you can check for an empty value and display a non-breaking space instead:
This question was written by Raymond Camden.
It was last updated on May 23, 2006 at 10:57:32 PM EDT.
CFML Referenced
Categories
Comments
Comment made by Gus on May 24, 2006 at 9:36 AM
A simpler solution might be to eliminate the cfif clause and just output: #thevalue#
Comment made by Raymond Camden on May 24, 2006 at 9:41 AM
Simpler, yes, but I always disliked that. It just felt "bad" to me to have the extra nbsp when it isn't necessary. But yes, that will work as well.
Comment made by dickbob on May 25, 2006 at 9:35 AM
I think for accessibility you should have a "-" instead of a as people using screen readers can lose their way in a table when a cell has no readable content.
Comment made by Craig Heath on October 10, 2006 at 5:43 PM
Or, you could simply write the retrieval query to not return a NULL but a space instead.
In that case, you wouldn't need to put logic into your output loop to determine what to display. You'd shunt the effort of replacing NULLs with spaces on the database...which, I'm told, should be more efficient.