Using javascript functions in HTML -
i creating small webpage add 2 input fields , place result in input field. have:
<html> <head> <title>calculator</title> <script type="text/javascript"> function add(){ var num1 = parseint(document.calc.num1.value); var num2 = parseint(document.calc.num2.value); var answer = (num1+num2); document.getelementbyid('res').value = answer; } </script> </head> <body> <form name="calc"> <input type ="button" name="add" value="+" onclick="add()"> <hr/> <input type ="text" name="num1" value=""> <input type ="text" name="num2" value=""> <hr/> <input type ="text" id="res" name="result" value=""> </form> </body> </html>
and getting following error when press + button.
uncaught typeerror: object not function
try changing function name add addnumbers or that.
Comments
Post a Comment