This topic is locked
[SOLVED]

 Conditional formatting of text

3/14/2012 2:46:19 AM
ASPRunnerPro General questions
S
sloftus author

Hi, I know how to conditionally format numbers i.e. negative values to red, positieve to black. This is shown clearly in the phprunner tutorial. However, what is the code snippet I need to use to change a text field based on its contents.. for example a status field reports that a task is either 'complete' or 'overdue'. I want the word 'overdue' to be in font colour red and 'complete' in black.
Thanks in advance.
Steve

Admin 3/14/2012

Take a look at http://xlinesoft.com/blog/2011/01/03/tutorial_conditional_formatting/ article first.
Here is the code snippet we need:

if strValue < 0 then

color="black"

else

color="red"

end if

strValue="<span style='color: " & color & ";'>" & strValue & "</span>"


If you want to display words 'complete' and 'overdue' instead of numbers modify it the following way:

if strValue < 0 then

color="black"

text = "complete"

else

color="red"

text="overdue"

end if

strValue="<span style='color: " & color & ";'>" & text & "</span>"
S
sloftus author 3/16/2012



Take a look at http://xlinesoft.com/blog/2011/01/03/tutorial_conditional_formatting/ article first.
Here is the code snippet we need:

if strValue < 0 then

color="black"

else

color="red"

end if

strValue="<span style='color: " & color & ";'>" & strValue & "</span>"


If you want to display words 'complete' and 'overdue' instead of numbers modify it the following way:

if strValue < 0 then

color="black"

text = "complete"

else

color="red"

text="overdue"

end if

strValue="<span style='color: " & color & ";'>" & text & "</span>"



Thanks Sergey,
I have solved the problem in a slight different way to change color and font weight conditionally on field content...
if (strpos($value, 'OVERDUE') !== FALSE)

{$color="red";
$value ='<strong>'.$value. '</strong> ';

}

else

if (strpos($value, 'in progress') !== FALSE)

{$color="Limegreen";$value ='<strong>'.$value. '</strong> ';}

else

if (strpos($value, 'done') !== FALSE)

{$color="Darkgray";}

else

{$color="black";}
$value="<span style='color: " . $color . ";'>$value</span>";
However I now want to gray out rows where the field Complete is 'Yes'. I have tried this code but it doesn't work...
if ($data["Complete"]=="Yes") // this line works when used to change row background colour.

$row["rowstyle"]='style="color:Gray"'; // this line does not work
Reading many forum posts it seems changing font colour in the list page using After Record Processed code snippets is a real problem.
Can you help Sergey?