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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
| <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>...</title>
<style type="text/css">
.compt {
font-weight:bold;
font-size:20px;
color:#ff0000;
}
label {
font-weight:bold;
}
</style>
</head>
<body>
<div id="c">
<p id="choix">
<label for="t">Entrez un nombre entier</label><br />
<input type="text" name="t" id="t" size="3" /><input type="button" value="go" onclick="go(this.previousSibling)" />
</p>
</div>
<script type="text/javascript">
var time, texte, n;
function go(t){
time=parseInt(t.value);
if(isNaN(time)){
alert("Merci de saisir un nombre entier!");
t.value="";
}
else{
n=document.createElement("span");
n.className="compt";
texte=document.createTextNode(time);
n.appendChild(texte);
document.getElementById("c").replaceChild(n,document.getElementById("choix"));
setInterval('if(time>0){time--};n.firstChild.data=time',1000);
}
}
</script>
</body>
</html> |
Partager