I need help in the time. i have a script that generated random images, but i need it that some how it does it my timer and not randomaly it should do it one after another. here is what i got Could some one please help.
PHP Code:
<html>
<body>
<script language="Javascript">
<!--
var images = new Array()
images[0] = 'glass.jpg'
images[1] = 'ball.jpg'
images[2] = '123.jpg'
var k = images.length;
var buff = new Array()
for (i = 0; i < k; i++){
buff[i] = new Image()
buff[i].src = images[i]
}
var theImage = Math.round(Math.random()*(k-1));
function imagesAppear(){
document.write('<td height="65" valign="top" cellpadding="2">')
document.write('<img src="'+images[theImage]+'">');
}
Thats just an example, but you can change the '2000' in the setTimeout to whatever you want it. 2000 means the image will rotate every 2 seconds, 5000 would be 5 seconds, etc... It can handle more pictures, all you have to do is add them to the array.
__________________
I'm only telling you how I would do it, not how its supposed to be done. ;)
boxxer03 thanks for you help, but i was unable to find a way to realate a to the image on the internet. If you know anyother way or if you know that any way to do it by asp it will be higly appreciated.
You can definetly do it. But it will be an excessive code because the problem you will have with relating pictures to dates is that if you have 5 pictures on the 6th day it needs to know to reset and since months stagger from 30-31 days and 28-29 (leap year) in February it creates a problem. So basically you would need a code that "knows" how many days are in each month and can break the month down and then assign a picture to each date and at the end of the month it also has to go from say image3 on the 31st of one month to image4 on the 1st of the next month instead of resetting for the month, but like I said it can be done, but it would be very time consuming and a large script. Your best bet would be to stick with using a timer to rotate the images periodically.
__________________
I'm only telling you how I would do it, not how its supposed to be done. ;)
its decent but it depends on what your trying to do if your trying to change pictures by the day then you don't need the month code, because this code displays two images - one depending on the month and one dpeneing on the day. but if you wanted it to display the images by date then just remove the month crap and put in your image urls for the days and just repeat them (because i'm sure you don't have 31 different pictures to display, but who knows). The only thing is that like i said before on the 31st it'll display one image and then 1st of the next month instead of going tothe next image it will just reset itself.
__________________
I'm only telling you how I would do it, not how its supposed to be done. ;)