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

29 lines
800 B
HTML

<html>
<head>
<title>Example 7.9</title>
<script>
function getValue()
{
var numMice = 12;
document.getElementById('first').innerHTML = (numMice);
changeValue(numMice);
document.getElementById('third').innerHTML = (numMice);
}
function changeValue(x)
{
x = 5;
document.getElementById('second').innerHTML = (x);
}
</script>
</head>
<body><table align="center" width = "70%"><tr><td><br />
<input type ="button" onclick="getValue()" value = "Can you change the number? Try it"><br />
<h3>The value of numMice is: <span id = "first">&nbsp;</span></h3>
<h3>The value of x, in the changeValue() function is: <span id = "second">&nbsp;</span></h3>
<h3>The value of numMice after calling the changeValue() function is: <span id = "third">&nbsp;</span></h3>
</td></tr></table>
</body>
</html>