1
Good afternoon,
Needed to calculate the average of the values inserted in the 4 text boxes, and only to learn the average result in the middle 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;
});
Hello, what have you done so far? Put a code there that agent can help you.
– PauloHDSousa