Im trying to create a timesheet page. Im struggling to work out how to add/subtract the times away from each other as its not adding the minutes as well.Can someone please help, i cant fine any answers online so far so hoping someone on here will be able to help.
It is only returning the hours and not minutes, im hoping the answer is simple and im just missing something?
Here is my code:
<button onclick="myFunction()">Cal</button><BR><BR>
<script>
function myFunction() {
var D1S = parseFloat(document.getElementById("D1S").value)
var D1F = parseFloat(document.getElementById("D1F").value)
document.getElementById("day1").innerHTML = D1F-D1S;
var D2S = parseInt(document.getElementById("D2S").value)
var D2F = parseInt(document.getElementById("D2F").value)
document.getElementById("day2").innerHTML = D2F-D2S;
var D3S = parseInt(document.getElementById("D3S").value)
var D3F = parseInt(document.getElementById("D3F").value)
document.getElementById("day3").innerHTML = D3F-D3S;
var D4S = parseInt(document.getElementById("D4S").value)
var D4F = parseInt(document.getElementById("D4F").value)
document.getElementById("day4").innerHTML = D4F-D4S;
var D5S = parseInt(document.getElementById("D5S").value)
var D5F = parseInt(document.getElementById("D5F").value)
document.getElementById("day5").innerHTML = D5F-D5S;
var D6S = parseInt(document.getElementById("D6S").value)
var D6F = parseInt(document.getElementById("D6F").value)
document.getElementById("day6").innerHTML = D6F-D6S;
var D7S = parseInt(document.getElementById("D7S").value)
var D7F = parseInt(document.getElementById("D7F").value)
document.getElementById("day7").innerHTML = D7F-D7S;
document.getElementById("total").innerHTML = (D1F-D1S) + (D2F-D2S) + (D3F-D3S) + (D4F-D4S) + (D5F-D5S) + (D6F-D6S) + (D7F-D7S);
}
</script>
Monday Start <input id="D1S" type="time" value="0.0"> Finish <input id="D1F" type="time" value="0.0"> <p id="day1"></p><BR>
Tuesday Start <input id="D2S" type="time" value="0.0"> Finish <input id="D2F" type="time" value="0.0"> <p id="day2"></p><BR>
Wednesday Start <input id="D3S" type="time" value="0.0"> Finish <input id="D3F" type="time" value="0.0"> <p id="day3"></p><BR>
Thursday Start <input id="D4S" type="time" value="0.0"> Finish <input id="D4F" type="time" value="0.0"> <p id="day4"></p><BR>
Friday Start <input id="D5S" type="time" value="0.0"> Finish <input id="D5F" type="time" value="0.0"> <p id="day5"></p><BR>
Staurday Start <input id="D6S" type="time" value="0.0"> Finish <input id="D6F" type="time" value="0.0"> <p id="day6"></p><BR>
Sunday Start <input id="D7S" type="time" value="0.0"> Finish <input id="D7F" type="time" value="0.0"> <p id="day7"></p><BR><BR>
Total - <p id="total"></p>