Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPEhtml>
- <html>
- <head>
- <meta charset=utf-8/>
- <title>Title</title>
- <style>
- body{ padding-top: 30px;}
- label,input{display:block;}
- </style>
- </head>
- <body>
- <p>Input radius value and get the volume of a sphere</p>
- <form action="" method="post" id="MyForm">
- <label for="radius">Radius</label>
- <input type="text" name="radius" id="radius" required>
- <label for ="volume">Volume</label>
- <input type="text" name="volume" id="volume">
- <input type="submit" value="Calculate" id="submit">
- </form>
- </body>
- </html>
- <script>
- function Volume() {
- var v;
- var radius=document.getElementById('radius').value;
- radius=Math.abs(radius);
- v=(4/3)* Math.PI * Math.pow(radius,3);
- v=v.toFixed(4);
- document.getElementById('volume').value=v;
- return false;
- }
- window.onload = document.getElementById('MyForm').onsubmit=Volume;
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement