
ayuda javascript
Publicado por Alberto (24 intervenciones) el 19/03/2015 17:02:43
Algo mal expresado? gracias.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<html>
<head>
<title>meses</title>
<script>
function calcul() {
var res = document.getElementById("resultat");
var mes = parseInt(document.getElementById('mes').value);
var ano = parseInt(document.getElementById('ano').value);
if mes in [1,3,5,7,8,10,12]
res.innerHTML = "Resultat: 31"
mes in [4,6,9,11]
res.innerHTML = "Resultat: 30"
else
si mes == 2 and (ano % 4 == 0 and ano % 100 != 0 or ano % 400 != 0);
res.innerHTML = "Resultat: 29"
else
res.innerHTML = "Resultat: 28"
var res = document.getElementById("resultat");
}
</script>
</head>
<body>
<h3>numero de dias:</h3>
<form action="">
<label>mes: </label>
<input type="text" id="mes" placeholder="1"><br>
<label>ano: </label>
<input type="text" id="ano" placeholder="2"><br>
<button type="button" onclick="calcul()">calcular</button>
</form>
<p id="resultat"></p>
</body>
</html>
Valora esta pregunta


0