Solved

Text Color

Posted on 2003-11-29
5
267 Views
Last Modified: 2013-12-24
Dear Experts,

I have a dynamic field that will be either High, Medium or low. Need to know how to change the text color based on the value. High=Red, Medium=Black, Low=Yellow.

Best regards,
AJ
0
Comment
Question by:aj10101
5 Comments
 
LVL 17

Accepted Solution

by:
anandkp earned 200 total points
ID: 9844518
Hi,

<cfset dynamic_field_value = "High"> <!--- this variable is set dynamically based on ur code ... i am assuming the value to be set as high for this example --->

<font face="verdana" size="2" color="<cfif comparenocase(dynamic_field_value,'high') eq 0>red<cfelseif comparenocase(dynamic_field_value,'medium') eq 0>black<cfelse>yellow</cfif>">
anandkp
</font>

hth

let me know

K'Rgds
Anand

PS : u can also use CFSWITCH CASE - if ur comfortable using it.
0
 
LVL 17

Expert Comment

by:Tacobell777
ID: 9846861
I was thinking more like something simpler like

<cfparam name="priority" default="medium"> <!--- you can leave this out if you don't need a default --->

<style type="text/css">
<!--
.high {
      color: #FF0000;
}
.medium {
      color: #000000;
}
.low {
      color: yellow;
}
-->
</style>


<span class="#priority#">Your text</span>
0
 
LVL 14

Expert Comment

by:Renante Entera
ID: 9847049
You can also have it this way :

<cfparam name="txtcolor" default="red">
<cfparam name="dynamicfld default"High">

<cfswitch expression="#dynamicfld#">
  <cfcase value="Medium">
    <cfset txtcolor="black">
  </cfcase>
  <cfcase value="Low">
    <cfset txtcolor="yellow">
  </cfcase>
  <cfdefaultcase>
  </cfdefaultcase>
</cfswitch>

<cfoutput>
  <input type="text" name="textfield" value="#dynamicfld#" style="font color:#txtcolor#;">
</cfoutput>

The value of the textfield will depend on the value being set to the parameter "dynamicfld".

Goodluck!
eNTRANCE2002 :-)
0
 
LVL 17

Expert Comment

by:anandkp
ID: 9881724
hello ???
0
 

Author Comment

by:aj10101
ID: 9883254
anandkp,

thanks for the help.
0

Featured Post

Easy, flexible multimedia distribution & control

Coming soon!  Ideal for large-scale A/V applications, ATEN's VM3200 Modular Matrix Switch is an all-in-one solution that simplifies video wall integration. Easily customize display layouts to see what you want, how you want it in 4k.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question