ASDV-WebDev/Semester 1/Chapter ZIPs/JavaScript/ch8/ex_8_13.html

32 lines
857 B
HTML

2023-04-18 14:06:12 +07:00
<html>
<head>
<title>Example 8.13</title>
<script type="text/javascript">
function getColors()
{
var ribbons = new Array("black", "white", "mauve","teal","ecru","buttercup","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.splice(1,2);
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>