Good evening, I'm with a RadioGroup that gives me three values: PM - Less Weight (The lower weight between the Outgoing Weight and Arrival Weight); PS - Output Weight; PC - Arrival Weight;
The system must take the value of the PptMotorista field and then perform the calculation by multiplying by the parameter selected above and dividing the result by a thousand so that it is displayed in the Freight Driver field.
<div class="row">
<div class="small-2 large-4 columns">
<label>PPT Motorista</label>
<input type="number" placeholder="170,00" name="PptMotorista" id="PptMotorista"/>
</div>
<div class="small-2 large-4 columns end">
<label>Frete Motorista</label>
<input type="number" name="FreteMotorista" id="FreteMotorista" readonly="readonly" tabindex="-1"/>
</div>
</div>
<div class="row">
<fieldset class="large-6 medium-6 columns">
<legend>Cálculo do Frete</legend>
<input type="radio" name="calculoFrete" value="PM" id="menorpeso" required checked><label for="menorPeso">Menor Peso</label>
<input type="radio" name="calculoFrete" value="PS" id="pesosaida"><label for="pesoSaida">Peso de Saída</label>
<input type="radio" name="calculoFrete" value="PC" id="pesochegada"><label for="pesoChegada">Peso de Chegada</label>
</fieldset>
</div>
<script type="text/javascript">
var bPptMotorista = document.getElementById( 'PptMotorista' );
var bFreteMotorista = document.getElementById( 'FreteMotorista' );
var bTipoPeso;
var bRadioGroupPeso = '';
$(document).ready(function(){
$("*[name='calculoFrete']").change(function(){
bRadioGroupPeso = ($(this).attr('value'));
});
});;
if (bRadioGroupPeso == 'PS'){
bTipoPeso = document.getElementById('PesoSaida');
} else if (bRadioGroupPeso == 'PC') {
bTipoPeso = document.getElementById('PesoChegada');
} else {
bTipoPeso = document.getElementById('PesoChegada') - document.getElementById( 'PesoTotal' );
}
bPptMotorista.onkeyup=calcula_frete;
bTipoPeso.change=calcula_frete;
function calcula_frete() {
bFreteMotorista.value = ((bTipoPeso.value / 1000) * bPptMotorista.value);
}
</script>
</body>
But the code I wrote, I do not know why you are not picking up the values, performing the calculation and playing in the Text of the Freight Driver. Can someone help me and check if the code has anything incorrect. Thank you.