Distância

HTML
<body> <form id="formulario"> <fieldset> <legend>distancia</legend> <label for="velocidade">velocidade:</label> <input type="text" name="velocidade"/> <label for="tempo">tempo:</label> <input type="text" name="tempo"/> <label for="distancia">distancia:</label> <input type="text" name="distancia"/> <a href="#" onclick="calculardistancia()">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
calculardistancia = function(){ var formulario = document.getElementById("formulario"); var velocidade = +formulario.velocidade.value; var tempo = +formulario.tempo.value; var distancia = velocidade*tempo; formulario.distancia.value = distancia.toFixed(2); }
Expand for more options Login