Re: ASP (alternating color table rows)

by Howard Rothenburg <hrothenb(at)bcpl.net>

 Date:  Sat, 20 Apr 2002 21:12:30 -0400 (EDT)
 To:  Matthew Ohlman <matthew(at)ohlman.com>
 Cc:  hwg-basics(at)hwg.org
 In-Reply-To:  hwg
  todo: View Thread, Original

<%
Dim objConn, objRec, strTable, strCmd, strColor
strCmd = "SELECT * FROM Authors"

Set objConn=Server.CreateObject("ADODB.Connection")
Set objCmd = Server.CreateObject("ADODB.Command")
set objRec = Server.CreateObject("ADODB.Recordset")

objConn.Open "Provider=Microsoft.Jet.OLEDB.3.51;Data Source=" & _
Server.MapPath("Biblio.mdb")
objRec.open strCmd, objConn, , 1, 1

sTable="<TABLE BORDER='1'><THREAD><TR>"
'Collect the Field Names
For Each fld in objRec.Fields
sTable = sTable & "<TD>" & fld.Name & "</TD>"
Next

'Build the table body
Do While Not objRec.EOF
X = X + 1
If X Mod 2 then
strColor = "00ffff"
Else
strColor = "#ffffff"
End If

sTable = sTable & "<TR bgcolor='" & strColor & "'>"
For Each fld in objRec.Fields
sTable = sTable & "<TD><font size = '2'>" & _
fld & "</font></TD>"
NextobjRec.MoveNext
sTable = sTable & "</TR>"
loop
Response.write sTable

objRec.Close
Set objRec = Nothing
objConn.Close
Set objConn = Nothing
%>


On Fri, 19 Apr 2002, Matthew Ohlman wrote:

> Date: Fri, 19 Apr 2002 12:55:45 -0500
> From: Matthew Ohlman <matthew(at)ohlman.com>
> To: hwg-basics(at)hwg.org
> Subject: ASP
>
> Hi List. I have been searching the web but can't find
> an easy way to do this. I have made a script, that
> searches a database, and displays the results into
> a table. How do I make every other table row rotate
> in color? Do I use CSS for this?
>
> The code is like this:
>
> If Request.form("what") = "name" Then
> SqlDepost = SqlDeposit & "WHERE name LIKE'%"  & _
> Request.form("search")& "%'"
> End If
>
> ' Then the table is just a normal table with this in it:
>
> <%=rsGlobalWeb("Name")%>
>
>
> Hope my explanation is clear enough!
> Thanks in advance,
> Matthew
>
>
>
>
> | Matthew Ohlman
> | Ohlman Pages
> | http://www.ohlman.com/
> "There's a difference between a philosophy and a bumper sticker. "
>       Charles M. Schulz
>
>

HTML Guild: hwg-basics mailing list archives, maintained by Web Professionals @ IWA

This page is part of a preserved archive of archives.hwg.org. The site is no longer active and its content is not maintained. For enquiries about this archive, write to archive(at)iwanet.org.