Well, I'm developing a form that will calculate the value of the freight and discount the debits to arrive at the net amount that the Driver has to receive. But I wanted some fields to display the values as the user completes the form.
For example the image, the "Weight Difference" field will calculate the "Output Weight" - "Weight of Arrival" to know the difference. Does anyone know of any JavaScript / jQuery tutorials that do something similar that I can build on?
<script type="text/javascript">
var tPesoSaida = document.getElementById( 'ps' );
var tPesoChegada = document.getElementById( 'pc' );
var tPesoTotal = document.getElementById( 'pt' );
tPesoSaida.onkeyup=calcula;
tPesoChegada.onkeyup=calcula;
function calcula() {
tPesoTotal.value = (tPesoSaida.value - tPesoChegada.value);
}
</script>
<div class="small-2 large-4 columns">
<label>Peso de Saída</label>
<input type="text" value="0" placeholder="37000" name="PesoSaida" id="ps"/>
</div>
<div class="small-2 large-4 columns">
<label>Peso de Chegada</label>
<input type="text" value="0" placeholder="37090" name="PesoChegada" id="pc"/>
</div>
<div class="small-2 large-4 columns">
<label>Diferença de Peso</label>
<input type="text" value="0" name="PesoTotal" id="pt" readonly="readonly" tabindex="-1"/>
</div>