ASDV-WebDev/Semester 1/Chapter ZIPs/JavaScript/ch7/ex_7_18a.html

36 lines
1.2 KiB
HTML

2023-03-30 13:50:50 +07:00
<html>
<head>
<title>Example 7.18a</title>
<script type="text/javascript" src="mySource.js"></script>
<script>
function getRange()
{
var num1 = parseInt(prompt("Enter low end of the range"));
var num2 = parseInt(prompt("Enter the high end of the range"));
var num3 = parseInt(prompt("Enter the number to check"));
var answer = checkRange(num3, num1, num2);
document.getElementById("line1").innerHTML = ("low end: " + num1 + "<br />");
document.getElementById("line2").innerHTML = ("high end: " + num2 + "<br />");
document.getElementById("line3").innerHTML = ("number to be checked: " + num3 + "<br />");
if (answer)
document.getElementById("line4").innerHTML = ("Number is in range");
else
document.getElementById("line4").innerHTML = ("Number is NOT in range");
}
</script>
</head>
<body>
<table align ="center" width ="70%"><tr><td colspan ="2">
<h1>&nbsp;</h2>
<h1>Get Range Function</h1>
<h3>Click to check a range</h3>
<p><input type="button" id="range" value="Enter a range" onclick="getRange();" /></p>
<div id = "line1">&nbsp; </div>
<div id = "line2">&nbsp; </div>
<div id = "line3">&nbsp; </div>
<div id = "line4">&nbsp; </div>
</td></tr>
</table></body>
</html>