Академический Документы
Профессиональный Документы
Культура Документы
Lista de Exercícios 1
Nome: Jean Trindade
Arquivo fat.js:
fuction fatorial(n){
if(n == 0)
return 1;
for(var fat = 1; n > 1; n = n - 1)
fat = fat * n;
return fat;
}
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Formulário</title>
<link rel="stylesheet" type="text/css" href="cs.css" />
<script type="text/javascript" src="scr.js"></script>
</head>
<body>
<div id="lb1">
<label id="label1">Digite uma idade entre 18 ou 60 anos</label>
</div>
<div id="lb2">
<label id="label2">Digite uma profissão: Supervisor, Gerente ou Operário</label>
</div>
<div id="formulario">
</div>
<div>
</html>
7. Arquivo em javascript scr.js:
function validitid(idade) {
var id = document.getElementById("idade");
if (idade < 18 || idade > 60) {
id.style.background = "red";
id = document.getElementById("label1");
id.style.color = "red";
else {
id.style.background = "white";
id = document.getElementById("label1");
id.style.color = "white";
}
}
function validitpro(profissao) {
var id = document.getElementById("profission");
if (profissao == "Supervisor" || profissao == "Gerente" || profissao == "Operário") {
id.style.background = "white";
id = document.getElementById("label2");
id.style.color = "white";
}
else {
id.style.background = "red";
id = document.getElementById("label2");
id.style.color = "red";
}