Put your JavaScript between script tags and into a function. Call the function from the onclick event.
HTML Code:<script type="text/javascript"> function calculate() { var wid = parseFloat (document.getElementById('width').value); //etc... } </script> <button onclick="calculate()">Calculate!</button>