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

27 lines
711 B
HTML

<html>
<head>
<title>Example 7.5</title>
<script>
function getAges()
{
var age = 0;
age = parseInt(prompt("How old is your grandmother?"));
pet();
function pet()
{
var age = parseInt(prompt("How old is your puppy?"));
num = 10;
document.getElementById('puppy').innerHTML = (age + num);
}
document.getElementById('granny').innerHTML = (age + num);
}
</script>
</head>
<body><table align="center" width = "70%"><tr><td><br />
<input type ="button" onclick="getAges()" value = "Find the age in 10 years"></button><br />
<h3>Your granny's age in 10 years: <span id = "granny">&nbsp;</span></h3>
<h3>Your puppy's age in 10 years: <span id = "puppy">&nbsp;</span></h3>
</td></tr></table>
</body>
</html>