I am using a HTML table to display some data. What I want is that when the data in the table cell is something specific (eg. Not Found) then I want that cell background color change to red. Basically change cells background-color according to the data present inside them. How can I achieve that any ideas? Thanks
Where is the data coming from?
I am using PHP to create temporary tables and fill data then display the temporary tables at the end.
Well then, can’t you use PHP to change the background colour of a cell depending on the value of the data? Or am I missing something…
I can and i have done that, but i want a JS solution.
So I have moved the topic to the JS forum.
Thanks !
Why?
Server-side scripting is far more reliable than client-side.
If it can be done sever-side, it should be. Save js for more interactive changes, things that you don’t want a re-fresh for, like if the data is updating dynamically while you watch.
Okay Thanks !
That’;s what I was thinking how I would do it (and have done it)
i.e. have the PHP add a class and let CSS do its magic.
But in addition to server-side table sorting, I would use JavaScript for that to save on the HTTP requests.
Using JavaScript to change CSS is OK for a page I don’t have control over, but if it’s one of mine, server-side is how I would do it.
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.