-2
<!DOCTYPE html>
<html>
<head>
<title>Exercicio 3</title>
<meta charset="utf-8">
</head>
<body>
<center><h1>Números dos Meses</h1>
<input type="number" name="numeros" max="12" min="1" id="mes">
<p id=></p>
<input type="submit" onchange="mes()">
<script type="text/javascript">
function mes(){
let mes = document.getElementById('mes').value;
switch (mes) {
case 1:
document.getElementById('mes').innerHTML = "Janeiro";
break;
case 2:
document.getElementById('mes').innerHTML = "Fevereiro";
break;
case 3:
document.getElementById('mes').innerHTML = "Março";
break;
case 4:
document.getElementById('mes').innerHTML = "Abril";
break;
case 5:
document.getElementById('num').value;
document.getElementById('mes').innerHTML = "Maio";
break;
case 6:
document.getElementById('mes').innerHTML = "Junho";
break;
case 7:
document.getElementById('mes').innerHTML = "Julho";
break;
case 8:
document.getElementById('mes').innerHTML = "Agosto";
break;
case 9:
document.getElementById('mes').innerHTML = "Setembro";
break;
case 10:
document.getElementById('mes').innerHTML = "Outubro";
break;
case 11:
document.getElementById('mes').innerHTML = "Novembro";
break;
case 12:
document.getElementById('mes').innerHTML = "Dezembro";
break;
}
}
</script>
</center>
</body>
</html>
I need to do this exercise : ** Enter the month number and print the month name. (switch)** But my code is not working the error appears on line 17 says that it is a syntax error and that I did not expect an Identifier I assume there is something else wrong someone can kindly show the way ? (OTHER ERROR) Does my button onclick not work what I do? (SOLVED)
After the
case X
should not have the two points?– Woss
switch (on =! 0) switched to switch(on) ?
– Andre Lacomski
yes I already changed I will reset to see
– Daniel Elias