0
Good afternoon guys, it is the following, I have two input fields in a form, in the first input I enter a value, then I click to calculate and the second input is filled with value that is calculated by multiplying the received value in the first input by 2,40. Until then everything is fine, but I would like the second input to be filled in when the first one lost the focus without the need to click the calculate button. follows the code and the example
function calcularUFM(){
var formulario = document.getElementById("formulario");
var valor_ufm = +formulario.valor_ufm.value;
var reais = (valor_ufm * 2.40);
formulario.reais.value = reais.toFixed(2);
}
<html>
<head>
<title></title>
<link rel="stylesheet" href="css/estiloImc.css" type="text/css" media="all">
<script type="text/javascript" src="js/scriptUfm.js"></script>
</head>
<body>
<form id="formulario">
<fieldset>
<legend>CACULADORA UFM / REIAIS</legend>
<label for="valor_ufm">VALOR EM UFM</label>
<input type="text" name="valor_ufm" /><br /><br />
<label for="reais"></label>
<input type="text" name="reais" disabled="disabled" /><br /><br />
<a href="#" onclick="calcularUFM();">calcular</a>
</fieldset>
</form>
</body>
</html>
Thanks Sam, it worked , thanks! I used the second option
– denilson
You are welcome. Learn how to thank in this link -> [tour]
– Sam