Please visit our sponsor
UNKNOWN '************************************** ' Name: Yet another Table coloring ' Description:This gives an alternating ' line color on tables, it also allows a r ' ealtime highlighting. ' By: Jonathan Barton ' ' ' Inputs:All explained int he code ' ' Returns:All explained within the code ' 'Assumes:None ' 'Side Effects:None 'This code is copyrighted and has limite ' d warranties. 'Please see http://www.Planet-Source-Cod ' e.com/xq/ASP/txtCodeId.6329/lngWId.4/qx/ ' vb/scripts/ShowCode.htm 'for details. '************************************** &lt;% 'The const's are for the colors and the Flag is needed Const sPrimaryColor = "WHITE" Const sSecondaryColor = "YELLOW" Dim bColorFlag dim lCounter 'This function does all the work for you. Function LineColor() bColorFlag = not bColorFlag If bColorFlag then LineColor = sPrimaryColor Else LineColor = sSecondaryColor End if End Function %&gt; <script language="VBScript"> Dim sRowOldColor Const sHighlightColor = "LIGHTBLUE" Sub Document_onclick() Dim sID 'Need to show the parent of the element that was clicked on If Window.Event.srcElement.tagName = "TD" Then sID = Window.Event.srcElement.ParentElement.id msgbox "ID = " & sID,,"This is the ID of the row." End If End Sub Sub Document_onmouseover() If Window.Event.srcElement.tagName = "TD" Then sRowOldColor = window.event.srcElement.ParentElement.bgcolor window.event.SrcElement.ParentElement.bgcolor=sHighlightColor End If End Sub Sub Document_onmouseout () If window.event.srcElement.tagName = "TD" Then window.event.srcElement.parentElement.bgcolor = sRowOldColor End If End Sub </script> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <title> Alternating Line Colors </title> </head> <body> <center> <p> <br> </p> <table width="80%" cellspacing="3" cellpadding="3" border="1"> &lt;% for lCounter = 1 to 10 Response.Write("<tr bgcolor="&quot; &amp; LineColor &amp; &quot;" id="&quot; &amp; lCounter &amp; &quot;">" & vbCrLf) Response.Write("<td><center>" & lCounter & "</center></td>" & vbCrLf) Response.Write("</tr>" & vbCrLf) next %&gt; </table> </center> </body> </html>