
altrow
Can someone direct me to a good site where I could learn how to alternate colors in a table. E.G. first row would be gray and next white until it reaches the end of the table. Thanks a million. Derek, I figure out that dbpaging migrate with Bill Wilkinson's help. Thanks a million for your help. It was a Chilisoft thang!<BR><BR>A<BR><BR>

RE: altrow
Glad you got the answer to your other problem. For this, while you're looping through your records, why couldn't you just include a counter and use something like this...<BR>Do/For<BR><BR>if (cntr mod 2 = 0) then<BR>'color = gray<BR>else<BR>'color = white<BR>endif<BR>cntr = cntr + 1<BR>d<BR>Loop/Next

RE: altrow
I dunno any sites. But it's a pretty easy question. And *LOTS* of ways to do it.<BR><BR>My favorite way:<BR><BR><%<BR>bgColors = Array("silver","white","pink","lightgreen")<BR>... <BR>rownum = 0<BR>...<BR>Do Until RS.EOF ' or however you are looping through the records<BR> rownum = rownum + 1<BR> Response.Write "<TD bgColor='" & bgColors(rownum MOD UBound(bgColors)) & ">" <BR> ...<BR>Loop<BR>%><BR><BR>If you are already using or displaying a "recnum" or some other loop counter, just use it instad of "rownum".<BR><BR>The trick: You can put as many colors as you like in that array and that code will *automatically* cycle through *all* the colors in the array. <BR><BR>Your homework: Figure out why/how it works.<BR>

RE: altrow
I think I see a goof! Shouldn't it be<BR><BR>bgColors(UBound(bgColors) MOD rownum) <BR><BR>instead of <BR><BR>bgColors(rownum MOD UBound(bgColors))

OOPS! A goof, but not same one!
Derek asked:<BR><BR>Shouldn't it be<BR> &n bsp;bgColors( UBound(bgColors) MOD rownum ) <BR> &nbs p;instead of <BR> &nbs p;bgColors( rownum MOD UBound(bgColors) ) <BR> <BR>Most definitely NOT!<BR><BR>But it *should* be<BR> &n bsp;bgColors( rownum MOD (1+UBound(bgColors)) ) <BR><BR>************<BR><BR>The MOD operator gives you the REMAINDER after you divide the number on the left by the number on the right.<BR><BR>Let's look at the results if we do it your way, for row numbers 0 through 6 with a bgColors array that has 4 elements.<BR><BR>rownum ( UBound(bgColors) MOD rownum )<BR>0 &n bsp;3 MOD 0 ==> **ERROR** (can't divide by 0)<BR>1 & nbsp;3 MOD 1 ==> 0<BR>2 &n bsp;3 MOD 2 ==> 1<BR>3 &n bsp;3 MOD 3 ==> 0<BR>4 &n bsp;3 MOD 4 ==> 3<BR>5 &n bsp;3 MOD 5 ==> 3<BR>6 &n bsp;3 MOD 6 ==> 3<BR>etc.<BR>3 MOD [anything larger than 3] will *always* be 3!<BR><BR>Not very interesting.<BR><BR>*************<BR><BR>Now my (revised) way:<BR><BR>rownum ( rownum MOD (1 + UBound(bgColors)) )<BR>0 &n bsp;0 MOD 4 ==> 0<BR>1 &n bsp;1 MOD 4 ==> 1<BR>2 &n bsp;2 MOD 4 ==> 2<BR>3 &n bsp;3 MOD 4 ==> 3<BR>4 &n bsp;4 MOD 4 ==> 0<BR>5 &n bsp;5 MOD 4 ==> 1<BR>6 &n bsp;6 MOD 4 ==> 2<BR>etc.<BR><BR>And it cycles repeatedly through 0, 1, 2, 3.<BR><BR>(I also left out the trailing ' in the bgColor='...' Sigh. Getting sloppy!)<BR><BR>So my revised code:<BR><BR>**************<BR><BR><%<BR> 0;%<BR>bgColors = Array("silver","white","pink","lightgreen")<BR>num BgColors = UBound(bgColors) + 1<BR>...<BR>rownum = 0<BR>...<BR>Do Until RS.EOF ' or however you are looping through the records<BR> rownum = rownum + 1<BR> Response.Write "<TD bgColor='" & bgColors(rownum MOD numBgColors)) & "'>" <BR> ...<BR>Loop<BR>%><BR><BR><BR><BR>

Read your array wrong!
Oh well. Sorry to all who might have read it about the incorrect post!

But helped me find my goof!

Now maybe Audrey can get her answer
Good luck, Audrey; Bill's post a few times ago should help you out.
Posting Permissions
 You may not post new threads
 You may not post replies
 You may not post attachments
 You may not edit your posts

Forum Rules

