aicirt
06-28-2006, 03:20 AM
i have created a while loop for some error checking in a clocking system... it's supposed to check the time sort of making sure 1 record is greater than another...
ie. reach office 08:00
lunch break 12:00
back from break 13:00
off work 18:00
somehow my code only works sometimes... and if it's only a few minutes difference it doesn't detect it... can someone help?
var a=0
var b =1
var count=0
while (count<=20)
{
var sClockin = document.Report.txtClockTime(a).value
var sClockout = document.Report.txtClockTime(b).value
sClockin = sClockin.replace(/:/gi,"");
sClockout = sClockout.replace(/:/gi,"");
if (parseInt(sClockout) < parseInt(sClockin))
{
alert ("Clock-Out time must be greater than or equal to Clock-In time");
return false;
}
if(a > 0 && b > 1)
{
if(parseInt(sClockin) < parseInt(sClockout))
{
alert("Latest Clock-In time must be greater than last Clock-Out time");
return false;
}
}
a=a+2;
b=b+2;
count++
}
}
ie. reach office 08:00
lunch break 12:00
back from break 13:00
off work 18:00
somehow my code only works sometimes... and if it's only a few minutes difference it doesn't detect it... can someone help?
var a=0
var b =1
var count=0
while (count<=20)
{
var sClockin = document.Report.txtClockTime(a).value
var sClockout = document.Report.txtClockTime(b).value
sClockin = sClockin.replace(/:/gi,"");
sClockout = sClockout.replace(/:/gi,"");
if (parseInt(sClockout) < parseInt(sClockin))
{
alert ("Clock-Out time must be greater than or equal to Clock-In time");
return false;
}
if(a > 0 && b > 1)
{
if(parseInt(sClockin) < parseInt(sClockout))
{
alert("Latest Clock-In time must be greater than last Clock-Out time");
return false;
}
}
a=a+2;
b=b+2;
count++
}
}