32 lines
834 B
HTML
32 lines
834 B
HTML
<html>
|
|
<head>
|
|
<title>Example 8.10</title>
|
|
<script type="text/javascript">
|
|
function getColors()
|
|
{
|
|
var ribbons = new Array("black", "white", "brown", "blue", "red");
|
|
var r = ribbons.length;
|
|
document.write("<table align = 'center'><tr><td>");
|
|
document.write("<br /> Old colors:</td></tr><tr><td>");
|
|
for (i = 0; i <= (r - 1); i++)
|
|
{
|
|
document.write(ribbons[i] + " ");
|
|
}
|
|
document.write("</td></tr><tr><td>Original length: " + r + "</td></tr><tr><td>");
|
|
ribbons.push("purple","green");
|
|
r = ribbons.length;
|
|
document.write("New colors:</td></tr><tr><td>");
|
|
for (i = 0; i <= (r - 1); i++)
|
|
{
|
|
document.write(ribbons[i] + " ");
|
|
}
|
|
document.write("</td></tr><tr><td>New length: " + r + "</td></tr>");
|
|
document.write("</table>");
|
|
}
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<button onclick="getColors()">See ribbon colors</button>
|
|
</body></html>
|
|
|