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

29 lines
879 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.24</title>
<script>
function getBracelet()
{
var bracelets = (prompt("How many bracelets do you want?"," "));
var check = bracelets % 1;
while ((isNaN(bracelets)) || (check != 0) || (bracelets < 0))
{
bracelets = prompt("Please enter a positive whole number. How many bracelets do you want?"," ");
var check = bracelets % 1;
}
document.getElementById("theOrder").innerHTML ="<h3>You are ordering " + bracelets + " bracelets.<br /> Thank you.</h3>";
}
</script>
</<head>
<body>
<table align ="center" width ="70%" ><tr><td colspan ="2">
<h1>&nbsp;</h2>
<h1>Order Your Bracelets Now!</h1>
<p><input type="button" id="bracelets" value="Order bracelets" onclick="getBracelet();" /></p>
</td></tr>
<tr><td id="theOrder"><p>&nbsp;</p></td></tr>
</table></body>
</html>