README.md

December 4, 2022 · View on GitHub

Simple row coloring

Description

The fastest way to do alternate colors of rows in your table (from recordset or something)

More Info

Submitted On
ByRammi
LevelIntermediate
User Rating4.6 (32 globes from 7 users)
CompatibilityASP (Active Server Pages), HTML
CategoryMiscellaneous
WorldASP / VbScript
Archive File

Source Code

<html>
<head>
<title>Alternate rows color</title>
</head>
<style>
.lnTrue {
 background : Gray;
 }

.lnFalse {
 background : Silver;
 }
</style>
<body>
<table>
 <tr>
 <th>Test</th>
 </tr>
<%
Dim objRs, blnLine

Set objRs = Server.CreateObject("ADODB.RecordSet")
objRs.Open "SOME QUERY HERE", "Connection string"


blnLine = False

Do Until objRs.EOF
 Response.Write "<tr class=""ln" & blnLine & """>" & _
   "<td>" & objRs(0) & "</td></tr>"
 blnLine = Not(blnLine) 
 objRs.MoveNext
Loop
Set objRs = Nothing
%>
</table>
</body>
</html>

--------------------------------------------
Blue bold parts are the most important...