ASDV-WebDev/Semester 1/Chapter ZIPs/JavaScript/ch04/ex_4_18.html

30 lines
731 B
HTML

2023-03-14 08:51:55 +07:00
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Example 4.18</title>
<script>
function countBeans()
{
var i = 0;
var beans = 12;
beanImage = ("<img src = 'blue_bean.jpg' >");
document.write("<table align = 'center'><tr><td>");
document.write("<h1>&nbsp;<br /> Here are your beans:</h1>");
for (i = 0; i < (beans - i); i++)
document.write(beanImage + "&nbsp; &nbsp;");
document.write("</td></tr></table>");
}
</script>
</head>
<body>
<table align ="center" width ="70%"><tr><td colspan ="2">
<h1>&nbsp;</h2>
<h1>Count Beans!</h1>
<tr><td><p>&nbsp;</p>
<p><input type="button" id="beans" value="Click to count beans" onclick="countBeans();" /></p>
</td></tr>
</table>
</body>
</html>