<html>
<head>
<title>Changing Font Color</title>
</head>
<body bgcolor="white">
<h1 id="colors">
The color is black.
</h1>
<h1>
<script type="text/javascript">
// <Peter Wen> <41752122> comment must be here.
// This function will change the color of the text to the name of the color you give it.
for (i=0; i < 4; i++)
var colorText = window.prompt ("Enter a number from 0 to 4: ");
function changeColor(colorText)
{ var text = document.getElementById("colors[i]");
text.innerHTML = "<font color=\""+colorText+"\">The color is "+colorText+".</font>";
}
// Declare, create, and put values into your color array here
var colors = new Array (5);
colors[0] = "green";
colors[1] = "blue";
colors[2] = "yellow";
colors[3] = "orange";
colors[4] = "blue";
// Create a loop that runs 4 times.
// Each time it asks the user for a number between 0 and 4.
// If an invalid input is entered, the color displayed should be black.
// Otherwise display the color at that index in the array.
</script>
</h1>
</body>
</html>
Bookmarks