Hi everyone,
I seem to be having a problem with a switch/case statement. Here's the function:
The function is basically supposed to get the hours worked in a week and set the right variables with the right values. Execpt h, all those variables are global.
I'm not getting the correct values at all with the if statement when h>8.
you can also check it out here
Thanks in advance
I seem to be having a problem with a switch/case statement. Here's the function:
The function is basically supposed to get the hours worked in a week and set the right variables with the right values. Execpt h, all those variables are global.
Code:
function setHours() { var h; for (var i = 0; i < 7; i++) { h = parseInt(document.EmpInfo['day'+i].value); switch (i) { case 0: case 1: case 2: case 3: case 4: if ( h > 8) { OT_hours =+ (h-8); reg_hours =+ 8; } else reg_hours =+ h; break; case 5: sat_hours =+ h; break; case 6: sun_hours =+ h; break; } // end switch } //end for alert('reg hours: ' + reg_hours + ' -- OT hours ' + OT_hours + ' -- sat hours ' + sat_hours + ' -- Sunday hours ' + sun_hours); } // end setHours
you can also check it out here
Thanks in advance
Comment