Advertisement
StefiIOE

presmetuvanje na volume

Feb 8th, 2020
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPEhtml>
  2. <html>
  3. <head>
  4.   <meta charset=utf-8/>
  5.   <title>Title</title>
  6.   <style>
  7.     body{ padding-top: 30px;}
  8.     label,input{display:block;}
  9.   </style>
  10. </head>
  11. <body>
  12. <p>Input radius value and get the volume of a sphere</p>
  13. <form action="" method="post" id="MyForm">
  14.   <label for="radius">Radius</label>
  15.   <input type="text" name="radius" id="radius" required>
  16.   <label for ="volume">Volume</label>
  17.   <input type="text" name="volume" id="volume">
  18.   <input type="submit" value="Calculate" id="submit">
  19. </form>
  20. </body>
  21. </html>
  22. <script>
  23.   function Volume() {
  24.     var v;
  25.     var radius=document.getElementById('radius').value;
  26.     radius=Math.abs(radius);
  27.     v=(4/3)* Math.PI * Math.pow(radius,3);
  28.     v=v.toFixed(4);
  29.     document.getElementById('volume').value=v;
  30.     return false;
  31.   }
  32.   window.onload = document.getElementById('MyForm').onsubmit=Volume;
  33. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement