April 15, 2024, 11:20:56 pm
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Welcome to Revolution X, where Coding meets Graphics.
 
  Home Help Search Arcade Affiliates Staff List Calendar Members Login Register  

Random Affiliate Box

Pages: [1]   Go Down
  Print  
Author Topic: Random Affiliate Box  (Read 428 times)
0 Members and 1 Guest are viewing this topic.
deathwilldie
Administrator
Adminitrator
Offline Offline

Posts: 1,769


View Profile WWW
Badges: (View All)
Tenth year Anniversary Nineth year Anniversary Level 5
« on: November 03, 2008, 04:01:12 pm »

This is the first Random Affiliate Box that I had some help making.

First you will need to put it in the Footers if you want it at the Bottom of the page.  If you want it at the top then put it in the headers it doesn't matter.


Code:
<script>
//Created by deathwilldie of Revolution X at www.revolutionx.smfforfree3.com
var tItLe="TITLE HERE"
var AffNum="NUMBER OF AFFILIATES HERE"
var randomizer=Math.round(Math.random()*AffNum)
var affs=[]
affs[0]=["0","SITE_URL","IMAGE_URL"];
for(e=0;e<affs.length;e++){
if(randomizer==affs[e][0]){
document.write("<table align='center' width='200' cellpadding='2' cellspacing='1'><th class='windowbg2' align='center'>"+tItLe+"</th><tr><td class='catbg' align='center'><a href='"+affs[e][1]+"'><img src='"+affs[e][2]+"' /></a></td></tr></table>") }}
</script>

Now its time to learn were to put the Title of the Affiliates Box.  Find this part.

Code:
var tItLe="TITLE HERE"

All you do is change the TITLE HERE part in it.

Next is the part were you put the affiliates in.

Find this part
Code:
affs[0]=["0","SITE_URL","IMAGE_URL"];
For the SITE_URL you put the Url of the site that you want the image to go to.
For the IMAGE_URL you put the image for the site.

Now adding more Affiliates
Quote
place
Quote
affs[0]=["0","SITE_URL","IMAGE_URL"];
Directly Beneath
Quote
affs[0]=["0","SITE_URL","IMAGE_URL"];
Make sure to increase the number in red by one everytime you add a new affiliate

Example of how to work code.
Quote
<script>
//Created by deathwilldie of SMF Codes at www.smcodes.smfforfree3.com
var tItLe="Title Here"
var AffNum="5"
var randomizer=Math.round(Math.random()*AffNum)
var affs=[]
affs[0]=["0","SITE_URL","IMAGE_URL"];
affs[1]=["1","SITE_URL","IMAGE_URL"];
affs[2]=["2","SITE_URL","IMAGE_URL"];
affs[3]=["3","SITE_URL","IMAGE_URL"];
affs[4]=["4","SITE_URL","IMAGE_URL"];
affs[5]=["5","SITE_URL","IMAGE_URL"];

for(e=0;e<affs.length;e++){
if(randomizer==affs[e][0]){
document.write("<table align='center' width='200' cellpadding='2' cellspacing='1'><th class='maintitle' align='center'>"+tItLe+"</th><tr><td class='row4' align='center'><a href='"+affs[e][1]+"'><img src='"+affs[e][2]+"' /></a></td></tr></table>") }}
</script>
see how the bold red number equals the largest number of all the other red numbers. or the ammount of affiliates plus one.
Report Spam   Logged

Share on Facebook Share on Twitter

Exilis
Optimistic & Creative
Global Moderator
Global Moderator
Offline Offline

Posts: 929


View Profile
Badges: (View All)
Tenth year Anniversary Linux User Combination
« Reply #1 on: November 03, 2008, 09:01:52 pm »

Instead of having to add 1 to the number each time, you can just put
Code:
affs[affs.length]=[affs.length,"SITE_URL","IMAGE_URL"];

And you can replace "AffNum" with this:
Code:
AffNum = affs.length;

The affiliates array would need to be declared before the AffNum declaration.
Report Spam   Logged

Global Mod, (sort of) at your service.

http://twitter.com/timothyaveni

Mojobojo82
MVP
MVP
Offline Offline

Gender: Male
Posts: 838


View Profile
Badges: (View All)
« Reply #2 on: June 22, 2009, 04:37:58 am »

Nice code.
But I'll stick with DwD's Affiliate box. Just because it has space for Our Code Cheesy
Report Spam   Logged






Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by EzPortal
Bookmark this site! | Upgrade This Forum
SMF For Free - Create your own Forum

Powered by SMF | SMF © 2016, Simple Machines
Privacy Policy