Copy link to clipboard
Copied
Is it possible to accomplish something like this with CF and CSS. Lets say i have the following status types(open,closed,canceled) and i have a table like this:
<cfquery name="job" datasource="#request.dsn#">
SELECT *
FROM tbl_jobs
</cfquery>
<table>
<tr>
<td>Date</td>
<td>Status</td>
</tr>
<cfoutput>
<cfloop query="jobs">
<tr>
<td>#job.date#</td>
<td>#job.status#</td>
</tr>
</cfloop>
</cfoutput>
</table>
Would it be possible to have the status <td> background change color depending on the status? So lets say when the status is "open" it will change <td> background to blue, and if the status is "closed" it will change it to red.
Or is there some way to accomplish this?
Yes easily.
Just one of a hundred possible ways:
<style>
td.open {background-color: blue;}
td.closed {background-color: red;}
td.cancled {background-color: green;}
</style>
...
<tr>
<td>#job.date#</td>
<td class="#job.status#">#job.status#</td>
</tr>
Copy link to clipboard
Copied
Yes easily.
Just one of a hundred possible ways:
<style>
td.open {background-color: blue;}
td.closed {background-color: red;}
td.cancled {background-color: green;}
</style>
...
<tr>
<td>#job.date#</td>
<td class="#job.status#">#job.status#</td>
</tr>
Copy link to clipboard
Copied
Thank you, that was exactly what i was looking for.