In the following code I want that when modifying any of the 2 inputs change the other one with its respective operation but taking the variable from the one that has just been edited.
function calcular()
{
var valor1= parseFloat( document.getElementById("valor1").value);
var valor2= parseFloat( document.getElementById("valor2").value);
var valor3= document.getElementById("valor2").value = (4000*valor1)/2.25;
var valor4= document.getElementById("valor1").value = (3.56*valor2)/4000;
}
<input type=text id="valor1" onKeyUp="calcular();" />
<input type="text" id="valor2" onKeyUp="calcular();" >
So when editing the field " valor1
", automatically the field " valor2
" is: (4000*valor1)/2.25
without " valor1
"change also and vice versa