This topic is locked

Changing background color in the list based on a field value

3/26/2009 6:16:51 AM
PHPRunner General questions
I
imendes author

How can I change the background color of a row on the list form, based on a field value?
For example, if the field 'State' contains the value '100', I want that row to turn green (background).
Thank you.
Phprunner 5.0

hfg 3/26/2009

There are actually a couple of ways to do this (searching the forums will yield others) my personal favorite is like this (where State is the field name):
Under Events - List Page
List Page: After Record processed
if($data["State"]=="100")
{

$row["rowstyle"]="style=\"background:green\"";

}
if($data["State"]=="200")
{

$row["rowstyle"]="style=\"background:yellow\"";

}
----End example---

A variation
if($data["FIELD"]<>"None")

{

$row["rowstyle"]="style=\"background:$data[rowcolor]\"";

}
---
You can also use the hex colors (#FFFFC6)

I
imendes author 3/26/2009

It works perfectly!
Thank you.