Lab15
This commit is contained in:
37
Chapter ZIPs/JavaScript/ch7/ex_7_16.html
Executable file
37
Chapter ZIPs/JavaScript/ch7/ex_7_16.html
Executable file
@@ -0,0 +1,37 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Example 7.16</title>
|
||||
<script type="text/javascript" src="mySource.js"></script>
|
||||
<script>
|
||||
function shipIt()
|
||||
{
|
||||
var shipCode = "FREEBIE";
|
||||
var userCode = prompt("Enter your code:");
|
||||
if (checkWord(shipCode, userCode))
|
||||
document.getElementById('result').innerHTML = ("Shipping is free!");
|
||||
else
|
||||
document.getElementById('result').innerHTML = ("Sorry, your code is not valid");
|
||||
}
|
||||
function checkWord(one, two)
|
||||
{
|
||||
var one; var two; var code = true;
|
||||
for (i = 1; i < 4; i++)
|
||||
{
|
||||
code = true;
|
||||
if (one != two)
|
||||
{
|
||||
code = false;
|
||||
two = prompt("Invalid code but try again or enter Q to quit:");
|
||||
if (two == "Q")
|
||||
break;
|
||||
}
|
||||
}
|
||||
return code;
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body><table align="center" width = "70%"><tr><td><br />
|
||||
<input type ="button" onclick="shipIt()" value = "Enter free shipping code"><br />
|
||||
<h3><span id = "result"> </span></h3>
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user