Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Web
Expertise: Intermediate
Apr 26, 2000

Simple JavaScript Alphabet

One obvious way to display or filter large recordsets is alphabetically. This function will take a page file and an optional frame name (defaults to _self) and create a row of capital letters linked to that page with an 'ALPHA' QueryString parameter for positioning or filtering the records on the target page. Easy variations include checking if the target is the same page and utilizing the '#' for repositioning.

This version also accommodates the use of additional QueryString parameters in the link by adding either a '?' or an '&' based on whether the linking page already has a '?' in it.

 
 function CreateAlphaLink(sPage, sFrame)
  {
  	var i;
  	var sAlpha;
  		
  	if(String(sFrame).toLowerCase() == "null") 
  		sFrame = "_self?";
  		
  	if (String(sPage).indexOf("?") != -1)
 		sPage += "&";	
 	else sPage += "?";
 
  	for(i = 1; i <= 26; i++)
  	{
  		sAlpha = "<a target=" + sFrame + " href=" + sPage;
  		sAlpha += "ALPHA=" + String.fromCharCode(64+i) + ">";
  		sAlpha += String.fromCharCode(64+i) + " </a>";
  		Response.Write(sAlpha);
  	}
  }
 }
Robert Grogan
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date