3
I am making a system for a virtual store, of which the user will have the value of the package. For example: R$ 12.000,00, however he will have the option to choose travel insurance through the code below:
Seguro Viagem?<br>
<input type='radio' name='Seguro' value='Sim'> Sim
<input type='radio' name='Seguro' value='Não'> Não
Is it possible to select Yes, the value of the trip insurance to be added to the value of the package and change the final value? Ex.:
( uninsured ) Value: R$ 12,000,00
When you click Yes, change to:
( with insurance ) Insurance: R$ 500,00 Value: R$ 12,500,00
I tried to use the code below, but it’s not working:
<script language="Javascript">
function soma(){
valorSeguro = 500.00;
valorPacote = 1200.00;
e = valorSeguro + valorPacote;
if(e.toFixed(2) == "NaN"){
document.getElementById("total").innerHTML = "USD 0.00";
}else{
document.getElementById("total").innerHTML = "USD "+e.toFixed(2)+"";
}
}
</script>
Seguro Viagem?<br>
<input type='radio' name='Seguro' onchange="soma()" value='Sim'> Sim
<input type='radio' name='Seguro' value='Não'> Não<br><br>
<div id="total" style="font-family:Arial; font-size:16px">USD 12.000,00</div>
Thank you!
Let’s delete the comments?
– Marconi