change font color with coldfusion

I want to make the font color red if the recordset returns NOT ASSIGNED!
Here is the relevent code.

<cfif #rsPickupsNew.USUCommonName# EQ "">
<cfset #rsPickupsNew.USUCommonName# = "NOT ASSIGNED!">
<cfelseif #rsPickupsNew.USUCommonName# EQ "Select or change your chemical here">
<cfset #rsPickupsNew.USUCommonName# = "NOT ASSIGNED!">
</cfif>

I have styles applied to the page, but I just want to change the color of the output if it is empty or "Select or change your chemical here"

Thanks.
jhmoenAsked:
Who is Participating?
 
Renante EnteraConnect With a Mentor Senior PHP DeveloperCommented:
Hmmm ... :-?  

Ah!  I got now the problem.  Have it this way :

<cfif Len(tempVariable)>
  <font color="0066FF">#tempVariable#</font>
<cfelse>
  #USUCommonName#
</cfif>

--------------
FINAL CODE
--------------
<cfoutput query="rsPickupsNew">
          <tr bgcolor=    
          <cfif (currentrow MOD 2) IS 1>
            "##FFFFFF"
            <cfelse>
            "##E9E9E9"
            </cfif>
            >
            <td class="Heading" align="center">
              <input name="HazIndex1" type="checkbox" id="HazIndex12" value="#rsPickupsNew.wasteID#">
            </td>
            <td class="Heading"><p><a href="/ehs/waste/hazwaste/pickups/edit.cfm?ID=#rsPickupsNew.wasteID#">&nbsp;#rsPickupsNew.HazIndex#-#rsPickupsNew.ContainerNum#</a></p></td>
            <td class="Heading"><p>#rsPickupsNew.Contents#</p></td>
            <!--- Some changes here for proper organization of codes --->
            <td class="Heading">
              <cfif Not Len(Trim(rsPickupsNew.USUCommonName)) OR rsPickupsNew.USUCommonName EQ "Select or change your chemical here">
                <cfset tempVariable = "NOT ASSIGNED!">
              </cfelse>
                <cfset tempVariable = "">
              </cfif>
              <p><strong><em>
                <cfif Len(tempVariable)>
                  <font color="0066FF">#tempVariable#</font>
                <cfelse>
                  #USUCommonName#
                </cfif>
              </em></strong></p>
            </td>
            <td class="Heading"><p>#rsPickupsNew.Name#</p></td>
            <td class="Heading"><p>#rsPickupsNew.Building#</p></td>
            <td class="Heading"><p>#rsPickupsNew.Room#</p></td>
            <td class="Heading"><p>#LSDateFormat(rsPickupsNew.RequestDate,'M/DD/YY')#</p></td>
          </tr>
        </cfoutput>

Kindly copy and paste the final code I've provided.  This should resolved the problem.


Goodluck!
eNTRANCE2002 :-)
0
 
Renante EnteraSenior PHP DeveloperCommented:
Hi jhmoen!

I'm going to revise your code and perhaps this is what you are looking for :

<cfset tempVariable = "">
<cfif Not Len(Trim(rsPickupsNew.USUCommonName)) OR rsPickupsNew.USUCommonName EQ "Select or change your chemical here">
  <cfset tempVariable = "NOT ASSIGNED!">
</cfif>

<font color=<cfif Len(tempVariable)>"FF0000"<cfelse>"0066FF"</cfif>>Your display information here.</font>

Hope this helps you.  Just try it and let me know if you need some explanations.


Goodluck!
eNTRANCE2002 :-)
0
 
Jerry_PangCommented:
what is the outertag before
<cfif #rsPickupsNew.USUCommonName# EQ "">
<cfset #rsPickupsNew.USUCommonName# = "NOT ASSIGNED!">
<cfelseif #rsPickupsNew.USUCommonName# EQ "Select or change your chemical here">
<cfset #rsPickupsNew.USUCommonName# = "NOT ASSIGNED!">
</cfif>
??

you need to change the class or style of that tag. chage it to sumthing like

<cfif #rsPickupsNew.USUCommonName# EQ "">
<span style="color:RED;">
<cfset #rsPickupsNew.USUCommonName# = "NOT ASSIGNED!">
<cfelseif #rsPickupsNew.USUCommonName# EQ "Select or change your chemical here">
<cfset #rsPickupsNew.USUCommonName# = "NOT ASSIGNED!">
</span>
<cfelse>
</cfif>
you could use fontcolor or class from your stylesheet
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

 
jhmoenAuthor Commented:
I have tried both, but don't quite follow.
Here is more of the code.
I am alternating color of the backround per line, but that should not matter.
I just want the text to be red if it is empty or "Select or change...."

<cfoutput query="rsPickupsNew">
          <tr bgcolor=      
          <cfif (currentrow MOD 2) IS 1>
              "##FFFFFF"
              <cfelse>
              "##E9E9E9"
              </cfif>
              >
            <td class="Heading" align="center">
              <input name="HazIndex1" type="checkbox" id="HazIndex12" value="#rsPickupsNew.wasteID#">
            </td>
            <td class="Heading"><p><a href="/somepage.cfm?ID=#rsPickupsNew.wasteID#">&nbsp;#rsPickupsNew.HazIndex#-#rsPickupsNew.ContainerNum#</a></p></td>
            <td class="Heading"><p>#rsPickupsNew.Contents#</p></td>
             <cfif #rsPickupsNew.USUCommonName# EQ "">
             <cfset #rsPickupsNew.USUCommonName# = "NOT ASSIGNED!">
             <cfelseif #rsPickupsNew.USUCommonName# EQ "Select or change your chemical here">
            <cfset #rsPickupsNew.USUCommonName# = "NOT ASSIGNED!">
             <cfelse>
            </cfif>
            <td class="Heading"><p><strong><em>#rsPickupsNew.USUCommonName#</em></strong></p></td>
            <td class="Heading"><p>#rsPickupsNew.Name#</p></td>
            <td class="Heading"><p>#rsPickupsNew.Building#</p></td>
            <td class="Heading"><p>#rsPickupsNew.Room#</p></td>
            <td class="Heading"><p>#LSDateFormat(rsPickupsNew.RequestDate,'M/DD/YY')#</p></td>
          </tr>
        </cfoutput>
0
 
Renante EnteraSenior PHP DeveloperCommented:
Hi jhmoen!

Is this what you mean :

<cfoutput query="rsPickupsNew">
          <tr bgcolor=    
          <cfif (currentrow MOD 2) IS 1>
            "##FFFFFF"
            <cfelse>
            "##E9E9E9"
            </cfif>
            >
            <td class="Heading" align="center">
              <input name="HazIndex1" type="checkbox" id="HazIndex12" value="#rsPickupsNew.wasteID#">
            </td>
            <td class="Heading"><p><a href="/somepage.cfm?ID=#rsPickupsNew.wasteID#">&nbsp;#rsPickupsNew.HazIndex#-#rsPickupsNew.ContainerNum#</a></p></td>
            <td class="Heading"><p>#rsPickupsNew.Contents#</p></td>
              <cfset tempVariable = "">
              <cfif Not Len(Trim(rsPickupsNew.USUCommonName)) OR rsPickupsNew.USUCommonName EQ "Select or change your chemical here">
                <cfset tempVariable = "NOT ASSIGNED!">
              </cfif>
            <td class="Heading"><p><strong><em><font color=<cfif Not Len(tempVariable)>"000000"<cfelse>"0066FF"</cfif>>#tempVariable #</font>
</em></strong></p></td>
            <td class="Heading"><p>#rsPickupsNew.Name#</p></td>
            <td class="Heading"><p>#rsPickupsNew.Building#</p></td>
            <td class="Heading"><p>#rsPickupsNew.Room#</p></td>
            <td class="Heading"><p>#LSDateFormat(rsPickupsNew.RequestDate,'M/DD/YY')#</p></td>
          </tr>
        </cfoutput>

Try it then let me know.


Regards!
eNTRANCE2002 :-)
0
 
jhmoenAuthor Commented:
That works great, but it only lists records that are NOT ASSIGNED! so somewhere we are losing the other records.
I have them in a repeat region. So the output would look something like:


RECORD 1             Aminodiphenyl
RECORD 2             1-Propanol
RECORD 3             4-Aminodiphenyl
RECORD 4             NOT ASSIGNED! (this being in red)
RECORD 5             NOT ASSIGNED! (this being in red)
RECORD 6             Light Tubes
RECORD 7             Light Tubes
RECORD 8             Light Ballasts
RECORD 9             Flammable liquids
RECORD 10           1,1-Dichloroethane
RECORD 12           acetylthiocholine iodide
RECORD 13           NOT ASSIGNED! (this being in red)

As it is now with your code, It looks like

RECORD 1            
RECORD 2            
RECORD 3            
RECORD 4             NOT ASSIGNED! (this being in red)
RECORD 5             NOT ASSIGNED! (this being in red)
RECORD 6            
RECORD 7            
RECORD 8            
RECORD 9            
RECORD 10          
RECORD 12          
RECORD 13           NOT ASSIGNED! (this being in red)

Thanks a bunch for staying with this!!
Jhmoen


0
 
Renante EnteraSenior PHP DeveloperCommented:
Ah!  OK.

Change this line :  
   <font color=<cfif Not Len(tempVariable)>"000000"<cfelse>"0066FF"</cfif>>#tempVariable#</font>

With this :
   <font color=<cfif Len(tempVariable)>"0066FF"</cfif>>#tempVariable#</font>

This should work.


Best regards!
eNTRANCE2002 :-)
0
 
jhmoenAuthor Commented:
still not it.
It yields the same results, the other records do not display.
0
 
Renante EnteraSenior PHP DeveloperCommented:
ha :-o

Let me help you in debugging.  

Do the following one at a time :
1.  Change it with this : <cfif Len(tempVariable)><font color="0066FF"></cfif>#tempVariable#<cfif Len(tempVariable)></font></cfif>
2.  OR Remove temporarily the "class" attribute for your "<td>" on that column.
3.  If it still not working, remove "<strong></strong>" and "<em></em>" tags.

Let me know which one resolved the issue.


Goodluck!
eNTRANCE2002 :-)
0
 
Renante EnteraSenior PHP DeveloperCommented:
By the way jhmoen, as I've reviewed the code.  I think #1 will resolve the issue no need to proceed with #s 2 and 3.

Just correct me if I'm wrong. #-o
0
 
jhmoenAuthor Commented:
entrance2002
Thanks so much for sticking with this, but It still only displays the NOT ASSIGNED! output, not the other records.
I tried all of your above 3 comments.  I really appreciate this.

If you come accross anything, please let me know.  I have upped the points for your efforts from 100 to 450.

HERE IS WHAT I AM CURRENTLY USING:
<cfoutput query="rsPickupsNew">
          <tr bgcolor=    
          <cfif (currentrow MOD 2) IS 1>
            "##FFFFFF"
            <cfelse>
            "##E9E9E9"
            </cfif>
            >
            <td class="Heading" align="center">
              <input name="HazIndex1" type="checkbox" id="HazIndex12" value="#rsPickupsNew.wasteID#">
            </td>
            <td class="Heading"><p><a href="/ehs/waste/hazwaste/pickups/edit.cfm?ID=#rsPickupsNew.wasteID#">&nbsp;#rsPickupsNew.HazIndex#-#rsPickupsNew.ContainerNum#</a></p></td>
            <td class="Heading"><p>#rsPickupsNew.Contents#</p></td>
              <cfset tempVariable = "">
              <cfif Not Len(Trim(rsPickupsNew.USUCommonName)) OR rsPickupsNew.USUCommonName EQ "Select or change your chemical here">
                <cfset tempVariable = "NOT ASSIGNED!">
              </cfif>
            <td class="Heading"><p><strong><em><cfif Len(tempVariable)><font color="0066FF"></cfif>#tempVariable#<cfif Len(tempVariable)></font></cfif></em></strong></p></td>
            <td class="Heading"><p>#rsPickupsNew.Name#</p></td>
            <td class="Heading"><p>#rsPickupsNew.Building#</p></td>
            <td class="Heading"><p>#rsPickupsNew.Room#</p></td>
            <td class="Heading"><p>#LSDateFormat(rsPickupsNew.RequestDate,'M/DD/YY')#</p></td>
          </tr>
        </cfoutput>
0
 
Renante EnteraSenior PHP DeveloperCommented:
And by the way, just an important reminder basing from your code to avoid redundancies.

When you are referring for a field within your "<cfoutput query=rsPickupsNew> ... </cfoutput>" :
   you may simply do something like this : #USUCommonName#
   instead of : #rsPickupsNew.USUCommonName#

Hope this makes sense.


Best regards!
eNTRANCE2002 :-)
0
 
jhmoenAuthor Commented:
That makes perfect sense... I will continue to code like that.
Thanks again.

THAT WORKED!!

I changed the </cfelse> to <cfelse> HERE:
cfif Not Len(Trim(rsPickupsNew.USUCommonName)) OR rsPickupsNew.USUCommonName EQ "Select or change your chemical here">
                <cfset tempVariable = "NOT ASSIGNED!">
              </cfelse>
                <cfset tempVariable = "">
              </cfif>

THANKS SO MUCH! It looks great!
0
 
Renante EnteraSenior PHP DeveloperCommented:
Ooopss ...  I apologized for that minor mistake.  

It's really funny, I gave you the corrected code but within the final code ... gassshhh ...  I'm too careless (lol).

Anyway, thanks for points and grade.  Hope to help you again.


Cheers!
eNTRANCE2002 :-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.