Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

count on cfif 2

Status
Not open for further replies.

gatetec

MIS
Mar 22, 2007
420
US
<cfoutput query="TBCResult">

.... bla..

<td>
<cfif #vComply# eq "Compliant">
<font color="0000FF">#vComply#</font>&nbsp;#Results#
<cfelseif #vComply# eq "Concurrent">
<font color="990000">#vComply#</font>&nbsp;#Results#
<cfelse>
<font color="FF0000">#vComply#</font> &nbsp;#Results#
</cfif>
</td>
</tr>

.. bla...

</cfoutput>

Is there a way to count #vComply# into three categories, "Compliant, Concurrent, Non-Compliant" and cfset so that I can display the sub-total of each category?
If #vComply# is not "Compliant or Concurrent", it is "Non-Compliant".

thx much
 
Code:
<cfset compliant=0>
<cfset concurrent=0>
<cfset noncompliant=0>

<cfoutput query="TBCResult">
<tr>
  <cfif #vComply# eq "Compliant">
    <cfset color="0000FF">
    <cfset compliant=compliant+1>
  <cfelseif #vComply# eq "Concurrent">
    <cfset color="990000">
    <cfset concurrent=concurrent+1>
  <cfelse>
    <cfset color="FF0000">
    <cfset noncompliant=noncompliant+1>
  </cfif>
<td><font color="#color#">#vComply#</font>&nbsp;#Results#</td>
</tr>
</cfoutput>

<cfoutput>
<p>Compliant count: #compliant#</p>    
<p>Concurrent count: #concurrent#</p>   
<p>Noncompliant count: #noncompliant#</p> 
</cfoutput>

r937.com | rudy.ca
 
or better yet use switch case statement
it reads faster.
<cfswitch expression="#vComply#">
<cfcase value="Compliant">
<cfset color="0000FF">
<cfset compliant=compliant+1>
</cfcase>

<cfcase value="Concurrent">
<cfset color="990000">
<cfset concurrent=concurrent+1>
</cfcase>

<cfcase value="Non-Compliant">
<cfset color="FF0000">
<cfset noncompliant=noncompliant+1>
</cfcase>
</cfswitch>


----------------------------------
htower
if( !succeed ) try( );
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top