Difference between revisions of "JavaScript: Exemplo de uso do switch"
From AdonaiMedrado.Pro.Br
(New page: <code lang="html"> <html> <head> <title>Minha Página</title> </head> <body> <input type="text" id="txtId" /> <input type="button" id="btOK" value="OK" onclick="javascript:executarF...) |
(No difference)
|
Revision as of 22:24, 12 September 2008
<html> <head> <title>Minha Página</title> </head> <body> <input type="text" id="txtId" /> <input type="button" id="btOK" value="OK" onclick="javascript:executarFuncao();" /> <script> function executarFuncao() { var i = document.getElementById("txtId").value; switch(i) { case "1": alert("Um"); break; case "2": alert("Dois"); break; case "3": alert("Três"); break; case "4": alert("Quatro"); break; case "5": alert("Cinco"); break; case "6": alert("Seis"); break; case "7": alert("Sete"); break; case "8": alert("Oito"); break; case "9": alert("Nove"); break; case "10": alert("Dez"); break; } } </script> </body> </html>