Change this line to
Code:
var dayName = new Array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
Day 0 is Sunday, Day 6 is Saturday.
To avoid repetition you need to shuffle your colors into a new order:-
Code:
<script type="text/javascript">
Array.prototype.shuffle = function() {
var s = [];
while (this.length) s.push(this.splice(Math.random() * this.length, 1)[0]);
while (s.length) this.push(s.pop());
return this;
}
var colors = new Array("aqua","blue","fuchsia","lime","magenta","navy","purple","red","white","yellow","black");
colors.shuffle();
alert (colors); // the shuffled array
for (var i =0; i<colors.length; i++) {
alert (colors[i]);
}
</script>
As has often been stated in this forum, document.write() is in effect obsolete. document.write() statements must be run before the page finishes loading. Any document.write() statement that runs after the page finishes loading will create a new page and overwrite all of the content of the current page (including the Javascript which called it). So document.write() is at best really only useful to write the original content of your page. It cannot be used to update the content of your page after that page has loaded. Use DOM methods instead.
Be aware that Java and Javascript are entirely different programming languages, in spite of the confusingly similar names. Rather like Austria and Australia!
"Let us be thankful for the fools. But for them the rest of us could not succeed. " - Mark Twain, US humorist, novelist, short story author, & wit (1835 - 1910)