GEOSKY Posted June 20, 2019 Share Posted June 20, 2019 THIS DOES NOT WORK <html> <head> <title>JavaScript: calculate two numbers</title> <script> function calme() { var a,b,c; a=Number (document.getElementById('a').value); b=Number (document.getElementById('b').value); c=a+b; document.getElementById ("x").innerHTML ="Total:"+c; } function clr() document.getElementById ("x").innerHTML="" document.getElementById ("a").value="" document.getElementById ("b").value="" </script> </head> <body> <p>www.Tutorjoes.com</p> Enter A Value :<input id="a" type="text" /> Enter B Value :<input id="b" type="text" /> <button onclick="calme();">Click Me</button> <button onclick="clr();">Clear</button> <p id="x"></p> </body> </html> Link to comment Share on other sites More sharing options...
Ingolme Posted June 20, 2019 Share Posted June 20, 2019 You are missing curly braces around the body of the clr() function. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now