Skip to main content
June 16, 2009
Answered

Is this possible

  • June 16, 2009
  • 1 reply
  • 470 views

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?

    This topic has been closed for replies.
    Correct answer ilssac

    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>

    1 reply

    ilssac
    ilssacCorrect answer
    Inspiring
    June 16, 2009

    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>

    June 18, 2009

    Thank you, that was exactly what i was looking for.