SHARE
TWEET

Untitled

a guest May 16th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function sum() {
  2.     var y = document.getElementById("txt1").value;
  3.     var z = document.getElementById("txt2").value;
  4.     var x = Number(y) + Number(z);
  5.     document.getElementById("demo").innerHTML = "[" + y + " ] + [ " + z + " ] = " + x;
  6.   }
  7.  
  8. <!doctype html>
  9. <html lang="en">
  10.   <head>
  11.     <title>Calculator</title>
  12.     <meta charset="utf-8">
  13.     <style>
  14.       html, body {
  15.         height: 100%;
  16.       }
  17.       body {
  18.         display: flex;
  19.         align-items: center;
  20.         justify-content: center;
  21.         flex-direction: column;
  22.         margin: 0;
  23.       }
  24.     </style>
  25.     <script src="index2.js"></script>
  26.   </head>
  27.  
  28.   <body>
  29.     <input type="number" id="txt1">
  30.     <input type="number" id="txt2">
  31.     <button onclick="sum()">Calculate</button>
  32.     <p id="demo"></p>
  33.   </body>
  34. </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