Forum Moderators: open
arr = new Array(
["http://www.google.com/test.jpg"],
["http://www.google.com/test2.jpg"]
);
now = new Date()
nowDate = now.getMinutes()
function change(){
if(nowDate > arr.length) { return; }}
now = new Date()
nowDate = now.getSeconds()
function change(){
document.getElementById("img").src = arr[new Date().getSeconds() - 1][0]
setTimeout('changeImg()',999)
}
Would if I add a variable to it like...
var conter=0.
And then an if comment or something that if counter=0. The script keeps going. I just don't know how to say "keep the script going."
if(counter=0 {?} Hope someone can help.
arr = new Array(
["http://www.google.com/test.jpg"],
["http://www.google.com/test2.jpg"]
);
now = new Date()
nowDate = now.getMinutes()
function changeImg(){
document.getElementById("img").src = arr[new Date().getSeconds() - 1setTimeout('changeImg()',999)
}
I tried adding a while or if command do the function.
while (arr.lenght<59){function changeImg(){
document.getElementById("img").src = arr[new Date().getSeconds() - 1setTimeout('changeImg()',999)
}}
But they don't work. Hope you can help.
<BODY onload="changeImg();"><img id="img" border="0"/>
This goes in external.
arr = new Array(
["http://www.google.com/test.jpg"],
["http://www.google.com/test2.jpg"]
);
now = new Date()
nowDate = now.getSeconds()
function changeImg(){
document.getElementById("img").src = arr[new Date().getSeconds() - 1][0]
setTimeout('changeImg()',999)
}
document.getElementById("img").src = arr[new Date().getSeconds()][0]
these lines can go as nowDate no longer used?
now = new Date()
nowDate = now.getSeconds()
The second problem totally unrelated is with a script I am trying to adjust to help me with day of the year. If you could help me with these two items I'll need to have someone send you a check for 20.00 for your services. I wouldn't want you to help me with those things for free. The day of the year item, I believe I have most of what you will need for that as well, just having trouble putting a few pieces together correctly. Please let me know if you will help me with this. Thank you Dave. Simone.
The first piece of code I gave you was a function I wrote. It contains code which tells your JavaScript interpreter how to calculate the day of the year for a date.
The second piece of code relies on the first piece of code, and is an example showing how the first piece of code works.
First:
function dayofyear(d) { // d is a Date object
var yn = d.getFullYear();
var mn = d.getMonth();
var dn = d.getDate();
var d1 = new Date(yn,0,1,12,0,0); // noon on Jan. 1
var d2 = new Date(yn,mn,dn,12,0,0); // noon on input date
var ddiff = Math.round((d2-d1)/864e5);
return ddiff+1; }
Second:
The usage of my function is as follows:
Code:
var a=new Date("July 1, 2007");
var b=dayofyear(a);
alert(b);
If my math is correct, and if the function is correct, this will give you the number 182.
This is the reply for each date.
Simple. Just grab today's date and stick it in.
Code:
var curdate=new Date(); // gets today's date
var cdnum=dayofyear(curdate);
document.write('Today is day number '+cdnum+' of the current year.');
By the way, my code is designed to always count Jan. 1 as day number 1.
Hope that helps, Simone