<script language="JavaScript">
var dt_deb = new Date();
function pluriel(nb) {
if (nb>1) {return "s"} else {return ""}
}
function FormatTemps(tps) {
var reste="Temps = ";
var min=Math.floor(tps/60);
var sec=tps-min*60
if (min>0) {reste+=min+" minute"+pluriel(min)+" "}
if (sec>0) {reste+=sec+" seconde"+pluriel(sec)}
return reste;
}
function CalculTemps() {
var dt=new Date()
tps = Math.round((dt.getTime() - dt_deb.getTime()) / 1000);
document.getElementById("Clock")=FormatTemps(tps);
setTimeout("CalculTemps()",1000);
}
CalculTemps()
</script>
You called CalculTemps() that sets the value of the textbox before the textbox is rendered by the browser. The textbox must exist first before the function can be called. The solution is to call it onload.
Comment