An ASP-based form for alternating background colors
Source: Internet
Author: User
<%
Const Adinteger = 3
Const adVarChar = 200
' Declare variables
Dim Myrecordset
Dim Iletter
Dim Field
Dim Straltcolor
Dim Bcolor
Bcolor = False
' This example takes advantage of an in-memory recordset and all you have to do is modify the portion of your data display.
Set myrecordset = Server.CreateObject ("ADODB. Recordset ")
MyRecordset.Fields.Append "ID", adinteger
MyRecordset.Fields.Append "Title", adVarChar, 25
MyRecordset.Fields.Append "Description", adVarChar, 255
Myrecordset.open
' Fill RS with sample data:
For iletter = ASC ("A") to ASC ("M")
Myrecordset.addnew
Myrecordset.fields ("ID"). Value = iLetter-64
Myrecordset.fields ("Title"). Value = "Letter:" & Chr (Iletter)
Myrecordset.fields ("Description"). Value = "Test the letters here:" & Chr (Iletter) & "."
Myrecordset.update
Next ' Iletter
' Move to the beginning of the head so that the following loop starts.
Myrecordset.movefirst
' Table header
Response.Write VbTab & "<tr>" & VbCrLf
For each Field in Myrecordset.fields
Response.Write VbTab & VbTab & "<td bgcolor=" "#CCCCCC" "><strong>"
Response.Write Field.name
Response.Write "</strong></td>" & VbCrLf
Next ' Field
Response.Write VbTab & "</tr>" & VbCrLf
Do as not myrecordset.eof
' Loop changes the background color of a cell
Bcolor = Not Bcolor
If Bcolor Then
Straltcolor = "#FFFFFF"
Else
Straltcolor = "#FF8040"
End If
' Loop changes the background color of a cell
Response.Write VbTab & "<tr>" & VbCrLf
For each Field in Myrecordset.fields
Response.Write VbTab & VbTab & "<td bgcolor=" ""
Response.Write Straltcolor
Response.Write "" ">" & Field.value & "</td>" & VbCrLf
Next ' Field
Response.Write VbTab & "</tr>" & VbCrLf
Myrecordset.movenext
Loop
' End ' table
Response.Write "</table>" & VbCrLf
' Close objects, release resources
Myrecordset.close
Set myrecordset = Nothing
%>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service