Click to See Complete Forum and Search --> : Color Change


eidalina20
04-16-2007, 12:53 AM
Hello everyone!
i really need help with this... i am stuck.. i know i am close but can't see it.
What i have to do is get seconds from the date listed.
time always changes therefore, seconds change

what i have problem with is changing the color of the "bluh" word. It should change each first number of the second. Meaning 10-19 one color 20-29 another color 30-39 another and so on.

it looks simple:
Mon Apr 16 01:41:10 EDT 2007
10
0
1 <-- color should change based on this numer
orange
blah

here is my code:

<html>
<head>

<script language=“JavaScript” type="text/javascript">

<!--
var colo= new Array(11)
colo[0]="red";
colo[1]="orange";
colo[2]="green";
colo[3]="blue";
colo[4]="brown";
colo[5]="yellow";
colo[6]="crimson";
colo[7]="darkgreen";
colo[8]="firebrick";
colo[9]="indigo";
colo[10]="lightblue";
var num
var thedate=new Date();
var secs=thedate.getSeconds();
secss=secs.toString();
document.write(thedate + "<br>");
document.write(secs + "<br>");
if(secs<=9)
{
num=secs;
}
else
{
num=secss.substr(1);
}
document.write(num + "<br>");
num= num * 1;
nump=num + 1;
document.write(nump + "<br>");
document.write(colo[nump]+"<br>");
document.write("<font color= colo[nump]>blah</font>");



</script>
</head>


thanx

mrhoo
04-16-2007, 01:44 AM
<script type="text/javascript">

onload=function(){
//define hoo to be anything but the body
Date.randomColor= function(){
var hoo= document.getElementsByTagName('body')[0];
var str = "rgb(", A = [], i=0;
while(i++<3) A.push(Math.round(Math.random() * 256));
str += A.join(",") + ")";
Date.timer= setTimeout('Date.randomColor()',10000);
hoo.style.color= str;
hoo.onclick= function(){clearTimeout(Date.timer)};
}
var wait=new Date().getSeconds();
wait=(10-wait%10)*1000;
Date.timer= setTimeout('Date.randomColor()',wait);
}
</script>

suntin
04-16-2007, 03:24 AM
document.write("<font color= colo["+nump+"]>blah</font>");

or am I thinking of eval() statements?... been too long now.

samanyolu
04-16-2007, 06:23 AM
document.write("<font color="+ colo[nump]+">blah</font>");

eidalina20
04-16-2007, 03:32 PM
hey, thanx guy it worked.. would anyone be able to help me out in one more thing.
instead of blah its now putting the date in color
after that i need to list nump number of succesive dates in altering colors

i donno how to do it heeeeeeelp

<html>
<head>

<script language=“JavaScript” type="text/javascript">

<!--
var colo= new Array(11);
colo[0]="red";
colo[1]="orange";
colo[2]="green";
colo[3]="blue";
colo[4]="brown";
colo[5]="yellow";
colo[6]="crimson";
colo[7]="darkgreen";
colo[8]="firebrick";
colo[9]="indigo";
colo[10]="lightblue";
var num
var i
var thedate=new Date();
var secs=thedate.getSeconds();
var day=thedate.getDate();
secss=secs.toString();
document.write(thedate + "<br>");
document.write(secs + "<br>");
if(secs<=9) {num=secs}
else {num=secss.substr(1)}
document.write(num + "<br>")
num= num * 1
nump=num + 1
document.write(nump + "<br>");

document.write(colo[nump]+"<br>");
document.write("<font color="+ colo[nump]+">");
document.write(day +"<br>");
Document.write("</font>");

i = 0
while (i <= nump)
{
day = day + 1
document.write("<font color="+colo[i]+">");
document.write(day +"<br>");
Document.write("</font>");
i= i++
}
-->
</script>
</head>