SHARE
TWEET

Accepting And Adding Two Numbers in JavaScript

Hiteshw11 Mar 26th, 2020 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE HTML>
  2.     <html>
  3.         <body>
  4.             <input type="text" placeholder="Enter first number" id="fnum"/>
  5.             <br>
  6.             <input type="text" placeholder="Enter second number" id="snum"/>
  7.             <br>
  8.             <button type="button" onclick="addition()">Submit</button>
  9.        
  10.         <script>
  11.             function addition()
  12.             {
  13.             var a=Number(document.getElementById('fnum').value);
  14.             var b=Number(document.getElementById('snum').value);
  15.             var c=a+b;
  16.             document.write("The sum is "+c);
  17.             }
  18.         </script>
  19.  
  20.         </body>
  21.     </html>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top