Good afternoon,
I needed to calculate the average of the values entered in the 4 text boxes, and only to see the result of the average in the average text box after all are filled
HTML
<div class="form-group">
<div class="col-xs-4">
<b>MAT</b>
<input type="text" name="txtMat" id="txtMat" class="form-control media" placeholder="" required>
</div>
<div class="col-xs-4">
<b>C NAT</b>
<input type="text" name="txtCNat" id="txtCNat" class="form-control media" placeholder="" required>
</div>
<div class="col-xs-4">
<b>Média</b>
<input type="text" name="txtMedia" id="txtMedia" class="form-control" placeholder="" disabled required>
</div>
</div>
<div class="form-group">
<div class="col-xs-4">
<b>LING</b>
<input type="text" name="txtLing" id="txtLing" class="form-control media" placeholder="" required>
</div>
<div class="col-xs-4">
<b>RED</b>
<input type="text" name="txtRed" id="txtRed" class="form-control media" placeholder="" required>
</div>
<div class="col-xs-4"></div>
</div>
JQUERY:
$('.media').change(function(){
var MAT = Number(document.getElementById("txtMat"));
var CNAT = Number(document.getElementById("txtCNat"));
var LING = Number(document.getElementById("txtLing"));
var RED = Number(document.getElementById("txtRed"));
var valorMAT = toNumber(MAT.value);
var valorCNAT = toNumber(CNAT.value);
var valorLING = toNumber(LING.value);
var valorRED = toNumber(RED.value);
MEDIA.textContent = ((valorMAT*45)+(valorCNAT*45)+(valorLING*5)+(valorRED*5))/100;
});