How do I change the calcular
button to auto sum with javascript!
[Example] typing in input name="campo1"
adds with input name="campo2"
automatically without needing calcular
button
It is a coin simulator because I want to R$
in input name="campo1"
and so when I for the money it will give me the value at the same time in input name="campo2"
Note: input name="campo2"
is multiplying by 23
and 25
I just want to leave auto sum to get the calcular
button
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>