Signature Rotation Code

Status
Not open for further replies.
Code:
function randInt(min,max)
{
     var div = (max - min) + 1
     var randNum = Math.random()
     for (var i = 0; i <= div - 1; i++)
     {
          if (randNum >= i / div && randNum < (i+1) / div)
          {return i + min}
     }
}


var abc = randInt(1,5);

if (abc == 1) {

     document.write("<\"Your 1. HTML-Banner-Code\">");

}

if (abc == 2) {

     document.write("<\"Your 2. HTML-Banner-Code\">");

}

if (abc == 3) {

     document.write("<\"Your 3. HTML-Banner-Code\">");

}

if (abc == 4) {

     document.write("<\"Your 4. HTML-Banner-Code\">");

}

if (abc == 5) {

     document.write("<\"Your 5. HTML-Banner-Code\">");

}

Keep in mind that simply copy/pasting this code into an HTML-accepted signature won't do anything, because it is raw Javascript. Also, document.write() will write only that to the page and display nothing else.

Try this out:

Code:
<div id="pics"><img src="http://link-to-picture.jpg" /></div>

<script type="text/javascript">
function randInt(min,max)
{
     var div = (max - min) + 1
     var randNum = Math.random()
     for (var i = 0; i <= div - 1; i++)
     {
          if (randNum >= i / div && randNum < (i+1) / div)
          {return i + min}
     }
}

var i = randInt(0,3);

var pics = new Array(4);

pics[0] = "http://link-to-picture.jpg";
pics[1] = "http://link-to-picture2.jpg";
pics[2] = "http://link-to-picture3.jpg";
pics[3] = "http://link-to-picture4.jpg";


var el = document.getElementById("pics");

el.innerHTML = "<img src=\"" + pics[i] + "\" />";
</script>

EDIT: However, I really don't think that's going to work, most forums don't allow HTML in signatures and even if they do, it usually filters out Javascript.
 
Wont work on here. HTML is disabled for signatures. We have had issues with HTML signatures breaking the forum so we disabled them.
 
Looks like you're going to have to dig out GD then....:D

Tkey
 
Crazed will be able to help you with GD, i'm not sure if it's even possiable.
Might be better to discuss this futher in you know where.....

Cheers,

~ Tkey
 
noooo!!!! whats gd? lol.

i got so close in having it work too :(

GD is a library for PHP used for working with images. You can make a PHP script to dynamically show your image.

However, I think dynamic images are not allowed here as well.
 
Status
Not open for further replies.
Back
Top Bottom