Paladin Computers
Home   Contact us

Specializing in MacroMedia's Cold Fusion Web Development.

Random Ad Display technique

This is a very simple way to create random advertising links in your web pages. Basically, you create an array, populate the array and pick a random entry in the array. Make sure you begin and end the array entries with a single quote and use double quotes within the entry. To add or delete entries, update the total number of entries in the second line of code (the '4' in my example), and make sure the array numbering is continuous. For example, if you deleted array position 2, you would rename position 3 to 2 and 4 to 3 so you would end up with positions 1,2 and 3.
 
For example:
<cfset displayText = ArrayNew(1)>
<cfset displayText[1] = '<img src="http://toshop.com/palsm.gif"><br>My logo'>
<cfset displayText[2] = '<a href="http://expersignal.com/">Expersignal.com</a>'>
<cfset displayText[3] = '<a href="http://allpme.com/">Allpme.com</a>'>
<cfset displayText[4] = '<a href="http://www.wave59.com/default.asp?refer=335&banner=0">Wave 59</a>'>

#displayText[randrange(1,ArrayLen(displayText))]#

To display your ad, just wrap CFOUTPUT around the last line. Here's an example. Reload this page to see it in action:


Home  |   Email and Web Hosting  |   Lat/Lon Lookup  |   Link Builder  |   Math  |  
Image Resizing Calculator  |   Naked Option Margin Calculator
Copyright © 2010, All rights reserved.
Maintained by Tom Nunamaker