27 lines
711 B
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"> </span></h3>
|
|
<h3>Your puppy's age in 10 years: <span id = "puppy"> </span></h3>
|
|
</td></tr></table>
|
|
</body>
|
|
</html>
|