Ways to get Alphabetical Paging for your ASP scripts

I did it a somewhat complicated way the first time. But there is an easier way.

First, the complicated way.

Rated:
by Aspin.com users
What do you think?
Example: My collection of Quarter Horse Pedigrees.
First, I created a field in the RECORDS table named ALPHA. Then using Access and Word, I copied the first letters of each horse's name into the ALPHA field from the NAMES field. By using ALT-click-drag I was able to copy only the first letters and paste them as a group back into the ALPHA field.

I created a new table called "LETTERS" with a field called "ABC" with a record for each letter of the alphabet. When this table is displayed, each letter is hyperlinked to the list of records that have the matching letter in their ALPHA field.

However, for NEW uploads, this would have to be automated. So I set it up so that when users upload a new file, the filename goes into the database as part of the upload and then there is a redirection to the edit.asp script that opens the newly created record. Inside the edit page code, I inserted the following bit of code (by Scott Campbell) that I have found so useful for so many different applications:

dim strFileName, str3, strExt

strFileName = Request.Form("x_TITLE")
'Getting the filename from our database and setting the string contents.
intHowLong = Len(strFileName) 'Getting the number of character contained within the filename.
str3 = intHowLong - intHowLong +1 'Subtracting the number of characters then adding 1. This is effectively removing the all but one letter.
strAlpha = Left(strFilename, str3) 'Isolating the first letter of the record title, the horse's name.
'response.write strAlpha


' Get fields from form
x_ALPHA = strAlpha
x_FILE = Request.Form("x_FILE")
x_SIZE = Request.Form("x_SIZE")
x_DATE = Request.Form("x_DATE")
x_TITLE = Request.Form("x_TITLE")
x_UPLOADBY = Request.Form("x_UPLOADBY")
x_REG_NO = Request.Form("x_REG_NO")

-----------------

An EASIER way to do this without so much messing with the database would be to use the code in this manner on the page of files listed by one letter of the alphabet.

EXAMPLES:
With the method above: http://quarter-horse-times.com/pedigrees/QHT_RECORDSlist.asp?alpha=M
With the simpler method below: http://quarter-horse-times.com/pedigrees/QHT_RECORDSlist2.asp?alpha=M

This code is used in QHT_RECORDSlist2.asp:

' Load Key for record
key = rs("ID")
x_ID = rs("ID")

x_FILE = rs("FILE")
x_SIZE = rs("SIZE")
x_DATE = rs("DATE")
x_TITLE = rs("TITLE")
x_UPLOADBY = rs("UPLOADBY")
x_REG_NO = rs("REG_NO")

dim strFileName, str3, strExt

strFileName = rs("TITLE")'Getting the title from our database and setting the string contents.
intHowLong = Len(strFileName) 'Getting the number of characters contained within the title content.
str3 = intHowLong - intHowLong +1 'Subtracting the number of characters then adding 1. This is effectively removing the all but one letter.
strAlpha = Left(strFilename, str3) 'Isolating the first letter of the record title, the horse's name.
'response.write strAlpha
x_ALPHA = strAlpha'making the first letter of the Title field the letter by which the records are filtered when matched to the querystring alpha=M or whatever

-------

The SQL for the list page looks something like this:
SELECT * FROM [RECORDS] WHERE ([ALPHA]='M') ORDER BY [TITLE] ASC
Of course, the actual code would be something like:

dim strAlpha
strAlpha = request.querystring("alpha")'tells which letter to sort by
"SELECT * FROM [RECORDS] WHERE [ALPHA]='"& strAlpha  &"'"&" ORDER BY [TITLE] ASC"

I have the Main Alphabetical List in a database table, but it could just as well be a static page. My hyperlinks look like this:
<a href="<% key = rs("ID") : If Not IsNull(key) Then Response.Write "QHT_RECORDSlist.asp?alpha="& x_ABC & "" End If %>"><b><font size="3"><%= x_ABC%></font></b></a>

This would work just as well (static links):
<a href="QHT_RECORDSlist.asp?alpha=M"><b><font size="3">M</a>
M
N

 

 

 

 

ASP Examples Menu of Active Server Pages scripts code Classic ASP

Classic ASP Active Server Pages Examples, code, tutorials, scriptsASP Examples Menu (below*)



Active Server Pages | ASP | Scripts | Tutorials | Code | Web Programming | Examples
Active Server Pages ASP code examples, tutorials, and snippets for use in Programming interactive websites.

NOTE: Recently changed hosting and url so some demos aren't working now because I haven't updated pathing; if you find omissions or errors let me know.
 

*

Multiple records per row with paging

Display multiple records per row

Get ID of newly inserted record, Classic ASP, Access Database

Javascript timer with ASP to keep track of time expired until login expires / timeout session is up

Multiple Javascript event functions triggered from single form onsubmit

Get Querystring key names along with querystring variables

ASP Youtube Downloader  Version FOUR
All ASP code. Allows user client side downloads of Youtube videos. You have the option to allow files to be saved directly to your site also.

ASP/PHP video downloader (Works better than ASP for large files)

Use ASP to dynamically parse a Youtube XML playlist to render to html.

Zip up an archive file of your site for backup if you need to restore website with ASP and free Zip Component.

Zip all files in a folder into an archive or backup file dynamically by specific file extension.

Sanitize or clean price cost field for database insertion or display.

Javascript image dimensions and image file size preview.

Put recordset into array, assign keys to the records then use record associated with specific array key as a variable elsewhere.

Access Database Interface Generator Wizard to read your table and field names and to create a table display.

Combining dropdown selection box menu with dynamic ASP database page.

How to redirect user to original page they tried to view before logging, after they are logged in.

Previous/Current/Next Records, or Buddy Ring Script

Custom ASP 404 page not found error script sends visitors to virtual folders

ASP Example: Combine ASP with Javascript for popup windows
dynamically sized to image dimensions.

ASP Example: How to use ASPJPEG to create thumbnails
Click for free Highly recommended thumbnailer for which you don't need Server access

ASPjpeg: How to re-scale aspect ratio of thumbnails by height instead of width.

ASP Example: What if your host has an older version of ASPJPEG that doesn't support gifs?

Using inline frames as "dynamic includes" (offline for updating)

Select Count Distinct Records for Access Database

Upload Image to folder and insert filename into database

Get date in such a way that it can be made part of a file name

Isolate a file name away from its path or extension or strip a path from a file name or strip characters from database field

User-customized on-the-fly stylesheet css files

Enhanced Page Hits Counter (also counts downloads and menu link hits)

Loop through array and compare to string with select case

Aphabetical Paging for your ASP scripts

Web Wiz Guide's Site Searcher Script modified as a file content indexer

Let Users Select How Many Records to View

Access Database for your PayPal IPN scripts

Miscellaneous collected code

You don't have to be a genius, just persistent, to write original Active Server Pages scripts

Software Recommendation: bare_bones_no_bells_and_whistles_asp_code_generator_database_interface_maker

--Lil at gmail.com