I need html code help
-
- Posts: 98
- Joined: Sun 19 Dec, 2004 18.42
- Location: Cambridgeshire
If you have it, I would recommend PHP. Otherwise, use javascript.
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.
Hope that helps -- should work. 
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>
