jplwebdesign
10-07-2005, 03:27 PM
Hi all - I thought I'd share this piece of code I use to randomize ads on pages. I know adsense allows you to randomize a particular ad, but I wanted a way to randomize different sized ads, not just colors. The below code does exactly this. Feel free to mess around with it. It can be programmed to randomize an infinite number of ads and colors. You can see it in action on this home page here --> http://www.petbabble.com if you hit refresh a few times you will see the two different ads I have rotating for my customer.
<%
dim images1, stDisplayImage1
Randomize
stDisplayImage1 = int(rnd * 2) + 1
%>
<%if stDisplayImage1 = 1 then%>
----adsense code #1
<%else%>
----adsense code #2
<%end if%>
<%
dim images1, stDisplayImage1
Randomize
stDisplayImage1 = int(rnd * 2) + 1
%>
<%if stDisplayImage1 = 1 then%>
----adsense code #1
<%else%>
----adsense code #2
<%end if%>