<html>
<head>
<title> If Demo Page </title>
<script type=”text/javascript”>
function ShowMessage()
// Assumes: gradeBox contains a grade (non-negative number)
// Results: displays if you got an A or a warning in response to a failing grade
{
var grade;
grade = parseFloat(document.getElementById(‘gradeBox’).value);
if (grade < 60) {
alert(‘You failed! Time to hit the books.’);
}
if (grade>89)
{
alert(‘You got an A’);
}
}
</script>
</head>
<body>
<p>
Your grade: <input type=”text” id=”gradeBox” size=6 value=””>
</p>
<input type=”button” value=”Click for Message” onclick=”ShowMessage();”>
</body>
</html>