PDA

View Full Version : picture ticker on refresh change pick



forgetmenow
10-09-2008, 11:20 AM
Hi guys and girls its me again...
I saw on here a while ago now a lady asking about how to put just a picture up and have it change every time the page is refreshed, i looked and thought that would be good for my site, but now i have lost the artical on here, can any one tell me where it is or maybe give me a codeing again for it?
thanks guys and girls.

codeexploiter
10-09-2008, 12:24 PM
Here is a demo page



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Untitled Document</title>
<style type="text/css">

</style>
<script type="text/javascript">
//You need to specify the path of your images if they are stored in another folder (not with the page).
//You need to store the image extension in the following string.
//As its been demonstrated multiple images can be seperated using comma operator
var imgs = "img1.gif,img2.gif,img3.gif,img4.gif,img5.gif,img6.gif,img7.gif,img8.gif,img9.gif,img10.gif,img11.gif,img12.gif,img13.gif,img14.gif,img15.gif,img16.gif";
imgs = imgs.split(',');
window.onload = function(){
var rnd = Math.floor(Math.random()*imgs.length); //Generates a random number that comes between 0 and the length of imgs array.
document.getElementById('ticker').src = imgs[rnd]; //Changes the image element source based on the random number.
};
</script>
</head>
<body>
<div>
<img id="ticker" src="" border="0" />
</div>
</body>
</html>


Hope this helps.

forgetmenow
10-09-2008, 02:26 PM
cant seem to get this to work?

bluewalrus
10-09-2008, 05:08 PM
I'd try putting this in the looking for a code or script forum.

rangana
10-10-2008, 01:15 AM
cant seem to get this to work?

Ensure to replace highlighted with the images at your end separated by a comma:


var imgs = "img1.gif,img2.gif,img3.gif,img4.gif,img5.gif,img6.gif,img7.gif,img8.gif,img9.gif,img10.gif,img11.gif,img12.gif,img13.gif,img14.gif,img15.gif,img16.gif";


So if you have three images, namely image1.jpg, image2.gif and image3.png then it shall be like this:


var imgs="image1.jpg,image2.gif,image3.png";


Hope that makes sense.

forgetmenow
10-10-2008, 09:43 AM
yes i have done that, THE PICKS SHOW BUT IS THERE ANY WAY TO LINK T=EACH PICK TO GO TO THE PAGE WHERE IT IS ON THE SITE, HERE IS MY TEST PAGE.
http://www.waggysfancydress.co.uk/test_page.html
sorry just noticed my capp lock was on, i am not shouting honest lol