Im trying to do a comparison with what the user type (his name - char) with the variable name (char). But idk how can i do that.
var nome=document.getElementById("nome").value;
var mat=document.getElementById("mat").value; //Disciplina
if (nome===name){
alert("Sua média é: "+ resultado);
} else {
alert("Error.");
return;
}
HTML Code:
<p class="p">Nome do aluno: <input class ="form-control" id="nome" type="text" name="name" placeholder="Preencha seu nome"/></p>
<button type="button" class="" onclick="media()">Calcular</button>
Javascript code:
function media() {
var nome=document.getElementById("nome").value;
var mat=document.getElementById("mat").value; //Disciplina
if (nome===name){
alert("Sua média é: "+ resultado);
} else {
alert("Error.");
return;
}
}
Nome do aluno:
– Bruno Jun 01 '19 at 20:54