0
So I have this code here and I have a difficulty, I would like to calculate the average of the notes that are placed in the input fields. If you can help.
<div class="">
<p>Media dos alunos</p>
<form class="" method="post">
<label>Aluno 01</label>
<input type="number" id="nota01" value="" max="10">
<br><br>
<label>Aluno 02</label>
<input type="number" id="nota02" value="" max="10">
<br><br>
<label>Aluno 03</label>
<input type="number" id="nota03" value="" max="10">
<br><br>
<label>Aluno 04</label>
<input type="number" id="nota04" value="" max="10">
<br><br>
<input type="button" onclick="javascript:calculo();" name="name" value="Enviar">
<input type="text" name="txtMedia" value="">
</form>
</div>
<script type="text/javascript">
function calculo() {
var nota01 = document.getElementById('nota01');
var nota02 = document.getElementById('nota02');
var nota03 = document.getElementById('nota03');
var nota04 = document.getElementById('nota04');
var resultado = (nota01 + nota02 + nota03 + nota04)/4;
return resultado;
}
</script>
</body>
Hi, I answered the same question on another page, read it and see if it helps you ok. [http://answall.com/a/141675/41104]
– Wilson Rosa Gomes