-1
Good afternoon! I have a form and a routine in JAVASCRIPT. My wish is that, from a typing, automatically appear the sum value. An example I’m looking for is the YOUSE, where by changing the value of the insurance covers, automatically the cost is displayed (without "TAB", "BUTTONS").
In my example, when you change, only with the TAB in N2 that updates. Another point, which despite being "pre-filled", is not available for example the sum of N1 and N2 (in case - 50).
FORM:
<input type="number" id="n1" value="20">
<input type="number" id="n2" value="30" onblur="calcularonline()">
<input type="text" id="n3" value="100">
<input name="idade" type="number" placeholder=0 id="id_idade">
<div id="resultado"</div>
<div id="resultado2"</div>
JAVASCRIPT
function calcularonline() {
var n1 = parseInt(document.getElementById('n1').value, 10);
var n2 = parseInt(document.getElementById('n2').value, 10);
document.getElementById('resultado').innerHTML = n1 + n2;
var n3 = parseInt(document.getElementById('n3').value, 10);
var n4 = (parseInt(document.getElementById('id_idade').value, 10))*2;
var n5 = 0;
if(n4>=10){
n5 = 10000;
}
document.getElementById('resultado2').innerHTML = n3 + n4 + n5;
}
Show. Willian, thank you for your attention!!
– José Cláudio Costa