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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Alternate Row Colors

Status
Not open for further replies.

WannaLearn

Programmer
Jul 10, 2001
210
0
0
US
Hello, I would like to change the color of a row after that row has been updated. How can I do that?
I know this code:
Code:
<tr align="center" valign="middle" bgcolor="###iif(currentrow MOD 2,DE('ffffff'),DE('efefef'))#">
changes the row color. But I would like to only color the row on any/all rows that have been updated. How can I do that? I know there is a <cfif> involved but not sure what to do.
Thanks.
 
well for this example I'm assuming there is a URL variable named 'update_id' and it will contain the ID number of the record just updated. The variable 'query.row_id' should be obvious.
Code:
###IIf(URL.update_id EQ query.row_id, DE('CCCCCC'),iif(currentrow MOD 2,DE('ffffff'),DE('efefef'))#

this is just a nested IIf. I have never tried to nest them before, but i see no reason it wouldn't work.
 
You put me in the right path! I did this, and works exactly like I want:
Code:
bgcolor="###IIf(form.afield_id EQ rInfoz.afield_id, DE('efefef'),DE('ffffff'))#"
Thanks.
 
I wanna say that "IIF()" is a slow function and Macromedia has hinted at eventually killing the slow functions.. I believe "may not work in future releases" is close to the exact terminology..

Its stupid if you ask me.. but in that case... Here's what I'd do

Put the following code somewhere around the top of the page.. before your cfoutput in which you want to use the alt coloring..

Code:
Set your colors:
<cfset ArrColors=ListToArray("##FFFFFF","##EFEFEF")>

Code:
Read your colors:
bgcolor="###ArrColors[ListFind(form.afield,rInfoz.afield_id)[b]+1[/b]]#"

Ok the way this works is it turns ArrColors into an array.. Array's start at #1 so

1: #FFFFFF
2: #EFEFEF

And then it uses the listfind function and the way listfind works, is if it finds it, it returns the position of the first time it found it.. since this variable is not a list, its only one element long.. So it would return "1".. If it does not find it, it returns 0..

That's what the bolded "+1" is for.. it adds 1 to the position, so when it can't find it, and it returns 0, it adds 1.. when it can find it and it returns 1, it adds and because 2.. Calling array position 2.

ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top