I have this simple example code, 3 textboxes. If I write numbers in the first two, it multiplies them and writes the result in the third one. However, if I run the code, I get an error saying: "ReferenceError: calc is not defined". Am I missing something?
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script language="text/javascript">
function calc()
{
var txt1 = (float) document.getElementById('text1').value;
var txt2 = (float) document.getElementById('text2').value;
document.getElementById('text3').value = (txt1 * txt2);
}
</script>
</head>
<body>
<table>
<tr>
<td><input type="text" id="text1" name="text1"></td>
<td><input type="text" id="text2" name="text2" onkeypress="calc();"></td>
<td><input type="text" id="text3" name="text3"></td>
</tr>
</table>
</body>
</html>
Update: Whoever wrote that "(float)" is causing the problem, was right. Thanks for the help.