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

26 lines
696 B
HTML

2023-03-30 13:50:50 +07:00
<html>
<head>
<title>Example 7.6</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?"));
document.getElementById('puppy').innerHTML = (age +10);
}
document.getElementById('granny').innerHTML = (age + 10);
}
</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>