: ok i worked for a long time and i am at this point, only problem is colors are not as i defined them, red is supposed to be only red color.
:
: "<html><title>Marks JS</title>
: <body> <font size = "4">
: <script language = "JavaScript">
: <!--Hide from non-Javascript browsers
: var Today = new Date() ;
: var DayNumber = Today.getDay() ;
:
: var Day;
: var weekday=new Array(14);
: weekday[0]="Sunday";
: weekday[1]="Monday";
: weekday[2]="Tuesday";
: weekday[3]="Wednesday";
: weekday[4]="Thursday";
: weekday[5]="Friday";
: weekday[6]="Saturday";
: weekday[7]="Sunday";
: weekday[8]="Monday";
: weekday[9]="Tuesday";
: weekday[10]="Wednesday";
: weekday[11]="Thursday";
: weekday[12]="Friday";
: weekday[13]="Saturday";
: var color=new Array(14);
: color[0]="red";
: color[1]="blue";
: color[2]="green";
: color[3]="orange";
: color[4]="black";
: color[5]="yellow";
: color[6]="gray";
: color[7]="red";
: color[8]="Monday";
: color[9]="blue";
: color[10]="green";
: color[11]="orange";
: color[12]="black";
: color[13]="yellow";
: i = Today.getDay();
: for(i=0;i<7;i++)
: {
: DayNumber = Today.getDay() +i;
: document.write("<font color = " + color[i] + " >"+"The day is " + weekday[DayNumber] + "<br/></font>") ;
: }
:
: //Stop hiding -->
: </script></font></table></body></html>"
:
It looks fine to me. I see each color only once, starting with red.
Here's how I would have coded it:
i = Today.getDay();
document.write("<font color = " + color[i] + " >"+"Today is " + weekday[i] + "<br/></font>") ;
i++;
while (i <> Today.getDay())
{
document.write("<font color = " + color[i] + " >"+"The day is " + weekday[i] + "<br/></font>") ;
i++
if (i == 7)
i = 0;
}
If you use this code, the arrays don't need to be "doubled", becasue i never gets above 6.