This is working some of the time, but not always, and I don't know what the problem is. I just submitted a record for 6/9/15 11:00 AM to 6/9/15 2:00 PM, and it came up with 185.00 hours.
You can post now and register later.
If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.
Question
ababcock
I have multiple submission forms that need to calculate total hours based on the begin time and end time entered. The script I have entered is:
<script>
document.getElementById('Submit').onmouseover = function(){
var date = document.getElementById('InsertRecordDate_of_Service').value;
if(date == "")
date = "1/1/2011";
var hour = document.getElementById('cbParamVirtual2').value;
if(hour =="")
hour="00";
var minute = document.getElementById('cbParamVirtual3').value;
if(minute == "")
minute = "00";
var ampm = document.getElementById('cbParamVirtual4').value;
document.getElementById('InsertRecordStart_Time').value = date + " " + hour + ":" + minute + " " + ampm;
var hour2 = document.getElementById('cbParamVirtual6').value;
if(hour2 =="")
hour2="00";
var minute2 = document.getElementById('cbParamVirtual8').value;
if(minute2 == "")
minute2 = "00";
var ampm2 = document.getElementById('cbParamVirtual7').value;
document.getElementById('InsertRecordEnd_Time').value = date + " " + hour2 + ":" + minute2 + " " + ampm2;
var start= new Date(document.getElementById('InsertRecordStart_Time').value);
var end = new Date(document.getElementById('InsertRecordEnd_Time').value);
var timeDiff = end - start;
var hh = Math.floor(timeDiff / 1000 / 60 / 60);
timeDiff -= hh * 1000 * 60 * 60;
var mm = Math.floor(timeDiff / 1000 / 60);
var totalmin= (mm+ (hh * 60)) ;
document.getElementById('InsertRecordTotal_Units').value = totalmin.toFixed(2);
};
</script>
This is working some of the time, but not always, and I don't know what the problem is. I just submitted a record for 6/9/15 11:00 AM to 6/9/15 2:00 PM, and it came up with 185.00 hours.
Does anyone know a way to make this work?
Link to comment
Share on other sites
5 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.