Add to Favorites    Make Home Page 2172 Online  
 Language Categories  
 Our Services  

Home » ASP Home » HTML Formatting Home » Paging with Alternating Colors

A D V E R T I S E M E N T

Search Projects & Source Codes:

Title Paging with Alternating Colors
Description This script will take the results of a query and sets up number of records per page (set at 10 currently) and alternates the colors of each record and provides a link to get the next 10 results.
Category ASP » HTML Formatting
Hits 365280
Code Select and Copy the Code
<%@language=vbscript%> <% 'Create the MyConnection Object and Open the connection to the database using your DSN Set MyConnection = Server.CreateObject("Adodb.Connection") MyConnection.open "DSN=DSNtest;Username=admin;Password=password;" 'Write your Query MyQuery = "Select FieldName from TableName" perpage = 10 Const adOpenForwardOnly = 0 Const adOpenKeyset = 1 Const adOpenDynamic = 2 Const adOpenStatic = 3 Const adLockReadOnly = 1 Const adLockPessimistic = 2 Const adLockOptimistic = 3 Const adLockBatchOptimistic = 4 Set myrs = Server.CreateObject("adodb.recordset") myrs.open myquery, MyConnection, adopenkeyset, adlockoptimistic If myrs.eof Then Response.Write "<table cellspacing=0 border=0 cellpadding=0 border=0 width=640 bgcolor=black><tr><td><table cellspacing=1 border=0 cellpadding=2 border=0 width=100% bgcolor=black><tr><td align=center bgcolor=Gray><font face=""Verdana"" size=1>Sorry, no records were found.</font></td></tr></table></td></tr></table>" ElseIf request("start") = "" Then start = 1 Else start = CInt(request("start")) End If torecs = ((start+perpage)-1) If torecs > myrs.recordcount Then torecs = myrs.recordcount End If i = 1 mypagenavigationbar = "" For n = 1 To myrs.recordcount step perpage If n <> 1 Then mypagenavigationbar = mypagenavigationbar & " | " If n = CInt(start) Then mypagenavigationbar = mypagenavigationbar & "<b>"&i&"</b>" Else mypagenavigationbar = mypagenavigationbar & "<a href=""" mypagenavigationbar = mypagenavigationbar & Request.ServerVariables("url") & "?start=" & n mypagenavigationbar = mypagenavigationbar & """>" mypagenavigationbar = mypagenavigationbar & i & "</a>" End If i = i + 1 Next i = 1 myrs.move start - 1 Response.Write "<table cellspacing=0 border=0 cellpadding=0 border=0 width=640 bgcolor=black><tr><td><table cellspacing=1 border=0 cellpadding=2 border=0 width=100% bgcolor=black>" Response.Write "<tr><td bgcolor=Gray align=right><font face=""Verdana"" size=1><b>Records </b> ("&start& "-" & torecs & " of " & myrs.recordcount&")  <b>Page(s)</b> : "&mypagenavigationbar&"</font></td></tr>" Response.Write "</table></td></tr><tr><td><table cellspacing=1 border=0 cellpadding=2 border=0 width=640 bgcolor=black><tr bgcolor=Silver>" Response.Write "<td align=Left><font face=""Verdana"" size=1>FieldNameHeading</font></td>" Response.Write "</tr>" iscolor = True For row = start To start + (perpage - 1) If myrs.eof Then Exit For If iscolor Then Response.Write "<tr bgcolor=Olive>" iscolor=False Else Response.Write "<tr bgcolor=Purple>" iscolor=True End If Response.Write "<td align=Left><font face=""Verdana"" size=1>"& Myrs("FieldName")& " </font></td>" Response.Write "</tr>" i = i + 1 myrs.movenext Next Response.Write "</table></td></tr></table>" 'Close the Recordset myrs.close Set myrs = Nothing 'Close the Connection MyConnection.close Set MyConnection = Nothing %>

Related Source Codes

Script Name Author
ııııııııııııııııııııı VyomWorld
Resistor color code reader A.Chermarajan.
Telephone Directory dhivya
card swapping game (Mini Project) nityanand
simple hangman-pascalsource Seabert
college dirtectory (Mini Project) msridhar
Poll Application John van Meter
ASP Daily Hit Counter. Tejaskumar Gandhi
To avoid null in asp environment using sql Sami
Maklumbalas webmaster
poll John van Meter
EasyASP Template Engine. TjoekBezoer
Basic Calculator using HTML & Javascript. Patrick M. D Souza
What servers support ASP ? VyomWorld
What is ASP? VyomWorld

A D V E R T I S E M E N T




Google Groups Subscribe to SourceCodesWorld - Techies Talk
Email:

Free eBook - Interview Questions: Get over 1,000 Interview Questions in an eBook for free when you join JobsAssist. Just click on the button below to join JobsAssist and you will immediately receive the Free eBook with thousands of Interview Questions in an ebook when you join.

New! Click here to Add your Code!


ASP Home | C Home | C++ Home | COBOL Home | Java Home | Pascal Home
Source Codes Home Page

 Advertisements  

Google Search

Google

Source Codes World.com is a part of Vyom Network.

Vyom Network : Web Hosting | Dedicated Server | Free SMS, GRE, GMAT, MBA | Online Exams | Freshers Jobs | Software Downloads | Interview Questions | Jobs, Discussions | Placement Papers | Free eBooks | Free eBooks | Free Business Info | Interview Questions | Free Tutorials | Arabic, French, German | IAS Preparation | Jokes, Songs, Fun | Free Classifieds | Free Recipes | Free Downloads | Bangalore Info | Tech Solutions | Project Outsourcing, Web Hosting | GATE Preparation | MBA Preparation | SAP Info | Software Testing | Google Logo Maker | Freshers Jobs

Sitemap | Privacy Policy | Terms and Conditions | Important Websites
Copyright ©2003-2024 SourceCodesWorld.com, All Rights Reserved.
Page URL: http://www.sourcecodesworld.com/source/show.asp?ScriptID=306


Download Yahoo Messenger | Placement Papers | Free SMS | C Interview Questions | C++ Interview Questions | Quick2Host Review