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

30 lines
824 B
HTML

<html>
<head>
<title>Example 7.10</title>
<script>
function getValue()
{
var numMice = 12;
document.getElementById('first').innerHTML = (numMice);
numMice = changeValue(numMice);
document.getElementById('third').innerHTML = (numMice);
}
function changeValue(x)
{
var x = 5;
document.getElementById('second').innerHTML = (x);
return 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>