1
How I change the button calcular
by auto sum with javascript !
[Example] when typing in input name="campo1"
he adds to the input name="campo2"
automatically without needing the button calcular
is a currency simulator because I want to put the R$
in the input name="campo1"
and so when I put the money he will give me the value at the same time on input name="campo2"
Obs: the input name="campo2"
is multiplying by 23
and 25
i just want to leave auto sum to take off the button calcular
this is the code : SCRIPT :
<script>
function soma()
{
var valor;
var campo = form.campo1.value;
if(campo >=1 && campo < 99){
valor=23;
}else{
valor=25;
}
form.campo4.value = parseInt(campo) * parseInt(valor)
}
</script>
HTML :
<form name="form">
<input name="campo1" id="demo4"><br>
<input name="campo2" value="" id="demo3" style="display: none;"><br>
<input name="campo4" readonly id="resultado"><br>
<input type="button" onclick="soma()" value="CALCULAR">
</form>
Thanks Isac ! know how I limit also the max of number type 3 before , and 2 after the , ??
– Andre Junior
@Andrejunior If you’re talking about currency formatting, you already have several questions for that, such as this
– Isac
Thanks again helped me a lot !
– Andre Junior
@You’re welcome, I’m glad I could help.
– Isac