SHARE
TWEET

why dont this work

a guest Aug 19th, 2019 124 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <html>
  2. <head>
  3.     <title></title>
  4. </head>
  5. <body>
  6. <div style="margin-left:30%;margin-top:10%;">
  7. <input id="calc">
  8. <button onclick="anybutton("add")">+</button>
  9. <button onclick="anybutton("sub")">-</button>
  10. <button onclick="anybutton("multiply")">*</button>
  11. <button onclick="show()">=</button>
  12.  
  13. </div>
  14. </body>
  15.  
  16. <script type="text/javascript">
  17.     function anybutton(opr) {
  18.         firstnum=document.getElementById("calc").value;
  19.         document.getElementById("calc").value=""
  20.         method=opr;}
  21.  
  22.     function show() {
  23.  
  24.         secnum=document.getElementById("calc").value;
  25.         if (method=="add"){document.getElementById("calc").value= Number(firstnum)+ Number(secnum);}
  26.             else if (method=="sub"){document.getElementById("calc").value= Number(firstnum)- Number(secnum);}
  27.         else if(method=="multiply"){document.getElementById("calc").value= Number(firstnum)* Number(secnum);}
  28.     }
  29.    
  30.  
  31. </script>
  32. </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