Cálculo da Pressão

HTML
<body> <form id="formulario"> <fieldset> <legend>equaçao de torriceli</legend> <label for="vi">vi:</label> <input type="text" name="vi"/> <label for="aceleracao">aceleracao:</label> <input type="text" name="aceleracao"/> <label for="espaco">espaco:</label> <input type="text" name="espaco"/> <label for="vf">vf:</label> <input type="text" name="vf" disabled="disabled"/> <a href="#" onclick="calcula()">Calcular</a> </fieldset> </form> </body>
CSS
img, table { width:165px; } fieldset { width:140px; } label { display:block; float:left;} label, input {width:68px; margin:3px 0; } th, td {border:1px solid #ccc; font-size:0.8em;}
JAVASCRIPT
calcula = function(){ var formulario = document.getElementById("formulario"); var vi = +formulario.vi.value; var aceleracao = +formulario.aceleracao.value; var espaco = +formulario.espaco.value; var vf=(vi**2+2*aceleracao*espaco)**1/2; formulario.vf.value = vf.toFixed(2); }
Expand for more options Login