<script>
<cfset rn = RandRange(1, 10)><cfoutput>var randomNumber = #rn#</cfoutput>var count = 1;var maxCount = 3;</script>
<script>
function check() {if (count <= maxCount) {var input = document.getElementById("guess").value;if (input == randomNumber) {alert("You got it. I picked " + randomNumber + "! Great job!");self
.location.href = "guess.cfm"}
else {var information = "";if(input < randomNumber) {information
= "You enter a less number."}
else {information
= "You enter a greater number."}
if (count == 3) {alert("Sorry, you got the max retry times.");self
.location.href = "guess.cfm"}
else {info
.innerHTML="<html><font color='red'><b>Sorry, you are wrong. There are " + (maxCount - count) + " times left! Try again!<br> " + information + "</b></font></html>";}
}
count
++;}
}
</script>
<html>
<head><title>Guess the number</title></head><body><b>Please enter number 1-10 to guess. There are 3 times for you!</b><form method="post"><table><tr><td colspan="2"><span id="info"></span></td></tr><tr><td>Input the Number:</td><td><input type="text" id="guess"></td></tr><tr><td colspan="2" align="center"><input type="button" value="Guess" onclick="javascript: check()"></td></tr></table></form></body></html>
联系客服