2
Here’s the code:
<script type="text/javascript">
function Enviar(){
var tempo = document.getElementById('tempo');
var veloc = document.getElementById('veloc');
var distancia = parseInt(tempo) * parseInt(veloc);
var litros = parseInt(distancia) / 12;
alert("Tempo gasto de viagem:"+tempo.value+"\nVelocidade média:"+veloc.value+
"\nDistância percorrida:"+distancia.value+"\nLitros gastos:"+litros.value);
}
</script>
</body>
But in the result it says that the variable distances and liters are "Undefined", and should contain the results of multiplication and division.
The 'time' and 'veloc' element probably do not contain any value can post HTML as well?
– Amadeu Antunes
<form id="form13"> Time spent traveling:<input type="text" id="time">hours<br> Speed Average:<input type="text" id="veloc">km/h<br> <input type="Submit" onclick="Send();" value="Send"> </form>
– Eduardo Balestrin