I need html code help

look
Posts: 29
Joined: Fri 25 Mar, 2005 19.52

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.
babyben
Posts: 394
Joined: Fri 25 Mar, 2005 14.34

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.
Orry Verducci
Posts: 98
Joined: Sun 19 Dec, 2004 18.42
Location: Cambridgeshire

If you have it, I would recommend PHP. Otherwise, use javascript.
cdd
Posts: 2622
Joined: Fri 15 Aug, 2003 14.05

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. :)
look
Posts: 29
Joined: Fri 25 Mar, 2005 19.52

Thanks. :o
Please Respond