Here is a script that is much smaller than the original. I have changed your hidden input elements into text input elements so that you can see the intermediate calculations. You can modify it to meet your own needs. I have also changed the submit button to a normal button, so the form will not submit until you change it.
[HIGHLIGHT=“”]
<!doctype HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>
<html>
<head>
<script type=“text/javascript”>
<!–
function calcul_sousdeux()
{ var allElems=document.formulaire.elements, A=new Array();
// put all form elements into array A()
for(var i=0;i<allElems.length;i++){ if(allElems[i].className !=“non”){A[A.length]=allElems[i]; } }
// note: A[0]=champ56, A[1]=champ58, A[2]=champ52, A[3]=champ53, A[4]=champ59, A[5]=champ60, A[6]=champ61, A[7]=Duree, A[8]=debut, A[9]=fini.
nbredeux= (A[2].value3600)-(A[0].value3600)+(A[3].value60)-(A[1].value60);
if (nbredeux<=0){ nbredeux=0; alert(“L’heure de début doit être inférieure à l’heure de fin !”); return; }
A[5].value= Math.floor(nbredeux/3600); // hrs worked
A[6].value= Math.floor((nbredeux-(A[5].value*3600))/60); // minutes worked
A[7].value= nbredeux; // total second worked
A[8].value = A[0].value +“:”+ A[1].value;
A[9].value = A[2].value +“:”+ A[3].value;
}
// ---------
//–>
</script>
<style type=“text/css”>
<!–
input { text-align:center; }
//–>
</style>
<title>Time Calcs</title>
</head>
Hi,
You can use this code in your page after head section of your web page and this coding is running.
<script type=“text/javascript”>
function display_c(start){
window.start = parseFloat(start);
var end = 0 // change this to stop the counter at a higher value
var refresh=1000; // Refresh rate in milli seconds
if(window.start >= end ){
mytime=setTimeout(‘display_ct()’,refresh)
}
else {alert("Time Over ");}
}
function display_ct() {
// Calculate the number of days left
var days=Math.floor(window.start / 86400);
// After deducting the days calculate the number of hours left
var hours = Math.floor((window.start - (days * 86400 ))/3600)
// After days and hours , how many minutes are left
var minutes = Math.floor((window.start - (days * 86400 ) - (hours *3600 ))/60)
// Finally how many seconds left after removing days, hours and minutes.
var secs = Math.floor((window.start - (days * 86400 ) - (hours 3600 ) - (minutes60)))
var x = window.start + “(” + days + " Days " + hours + " Hours " + minutes + " Minutes and " + secs + " Secondes " + “)”;