Page 1 of 1

I need html code help

Posted: Thu 14 Apr, 2005 22.31
by look
Can anyone give me the code where everytime the page is visited , or refreshed the banner image changes. Not everyday, but everytime it is visited. Thanks.

Posted: Fri 15 Apr, 2005 01.50
by babyben
You can't do it in HMTL.. you want it in javascript or php?

javascript - it's done on the persons computer.

php - it's done your hostings computer.

Posted: Fri 15 Apr, 2005 16.17
by Orry Verducci
If you have it, I would recommend PHP. Otherwise, use javascript.

Posted: Fri 15 Apr, 2005 16.17
by cdd
Hi!

I'd reccomend PHP too but because I'm more adept at Javascript and very few free web hosts support PHP you might find this useful.

Put this code wherever you want it to appear.

Code: Select all

<script language="JavaScript">
var piccies = new Array()
piccies[0] = 'picture1.jpg'
piccies[1] = 'picture2.jpg'
piccies[2] = 'picture3.jpg'

//If you want to have a greater number of pictures add additional items per line following the format above. Amend the filenames in inverted commas to those correct to the images you want to be available in your random selection.
 The pictures can be called anything you want, not just picture1, picture2, etc.
var j = 0
var p = piccies.length;

var choosernd = new Array()
for (i = 0; i < p; i++){
   choosernd[i] = new Image()
   choosernd[i].src = theImages[i]
}

var whichImage = Math.round(Math.random()*(p-1));
document.write('<img src="'+piccies[whichImage]+'">');
</script>
Hope that helps -- should work. :)

Posted: Fri 15 Apr, 2005 17.26
by look
Thanks. :o