Better alternating row colors
Present a simple method for creating tables with alternating row colors.
AI
AI 요약: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
소스 코드
<P><Strong>Alternating Row Colors:</Strong></P>
<P>Using an <B>array</B> and two <B>variables</B> along with the <B>MOD</B> function
you can create many various effects for alternating row colors in your tables.
The Key is the <B>MOD</B> function, this creates an incrementing loop through the array.
</P>
<P>Here's how easy it is; (The two hilighted sections are where the action takes place.)</P>
<PRE style="background:#eeeeee;"><STRONG>Dim colorset, i, numcolors
</STRONG>'<EM>/--- This is your array of colors to use. -------------\</EM><STRONG>
colorset = split("<font color=Green>White,LightGrey,SkyBlue,Yellow</font>",",")
numcolors = ubound(colorset)+1
Do
Response.Write "<font color=Green><TR style=""background:"</font> & <span style="BACKGROUND: yellow">colorset(i mod numcolors)</span> & "<font color=Green>;""></font>"
</STRONG> <EM>'[-- Add your column data in here --]</EM>
<STRONG> Response.Write "<font color=Green></TR></font>"
<span style="BACKGROUND: yellow">i = i + 1</span> </STRONG>'<EM><-- Increment the counter</EM><STRONG>
Loop</STRONG></PRE>
<P>Of course the array could be what ever information you want to cycle through, like class names from a stylesheet, or...</P>
원본 댓글 (3)
Wayback Machine에서 복구됨