I have a question. I am struggling in my JavaScript class and need some help. I have to make a style viewer with at least 20 differed style classes. And it must call one of the style classes at random each time it is called. I also have to create an array of at least 5 backgrounf colors. My stylize() function selects one of the at random also. Below is what I have so far. Please help!
<html>
<head>
<title>HTML and JavaScript</title>
<link href="capstone10.css" rel="stylesheet" type="text/css"></link>
<script type="text/javascript">
function select() {
index = Math.floor(Math.random() * 20);
if (index > 20) index = 1;
var s = "myStyle" + index;
var e = document.getElementById("MessageText");
e.className = s;
setTimeout("select()", 1500);
return;
}
function setbackground() {
var bgcolour = ['blue,'white','brown','purple','red'];
setTimeout( "setbackground()", 5000); // 5000 milliseconds delay
var index = Math.floor(Math.random() * bgcolour.length);
var ColorValue = bgcolour[index];
document.getElementById('MessageText').style.backgroundColor = ColorValue;
return;
}
</script>
</head>
<body onLoad="stylize()">
<table align="center" border="1" bordercolor="black">
<tr>
<td align="center">
<font size="3"><b>STYLE CLASS VIEWER</b></font>
</td>
</tr>
<tr>
<td align="center" height="300" width="700" class="myStyle1">
<div id="MessageText" class="myStyle1">
Hello World Wide Web!
</div>
</td>
</tr>
</table>
</body>
</html>
This is my .css sheet
.myStyle1 {font-family:arial; color:black; font-size:12}
.myStyle2 {font-family:arial; color:green; font-size:18}
.myStyle3 {font-family:arial; color

urple; font-size:22}
.myStyle4 {font-family:arial; color

range; font-size:26}
.myStyle5 {font-family:arial; color:red; font-size:30}
.myStyle6 {font-family:verdana; color:yellow; font-size:12}
.myStyle7 {font-family:verdana; color:blue; font-size:18}
.myStyle8 {font-family:verdana; color:black; font-size:22}
.myStyle9 {font-family:verdana; color

ink; font-size:26}
.myStyle10 {font-family:verdana; color:green; font-size:30}
.myStyle11 {font-family:times; color

range; font-size:12}
.myStyle12 {font-family:times; color:red; font-size:18}
.myStyle13 {font-family:times; color:green; font-size:22}
.myStyle14 {font-family:times; color:blue; font-size:26}
.myStyle15 {font-family:times; color

range; font-size:30}
.myStyle16 {font-family:courier; color:green; font-size:12}
.myStyle17 {font-family:courier; color

urple; font-size:18}
.myStyle18 {font-family:courier; color:black; font-size:22}
.myStyle19 {font-family:courier; color:red; font-size:26}
.myStyle20 {font-family:courier; color:green; font-size:30}
Thanks