I am using JQuery to readily update an input field with a total number of hours that is generated by using datetimepicker to compare two dates selected by the user. My problem is after the input field #numberOfHours
is updated with the result from this function:
$('#startForm').keyup(function () {
var start_actual_time = $('#datetimepicker').val();
var end_actual_time = $('#datetimepicker2').val();
$hourlyRate = $('#hourlyRate').val();
$fixedPrice = $('#fixedRate').val();
//CALCULATE TIME BETWEEN TWO DATES
start_actual_time = new Date(start_actual_time);
end_actual_time = new Date(end_actual_time);
var diff = end_actual_time - start_actual_time;
var diffSeconds = diff / 1000;
var HH = Math.floor(diffSeconds / 3600);
var MM = Math.floor(diffSeconds % 3600) / 60;
var formatted = ((HH < 10) ? ("0" + HH) : HH) + "." + ((MM < 10) ? ("0" + MM) : MM);
$totalHours = formatted;
$('#numberOfHours').val($totalHours); //this is getting updated but not passed on to the PHP insert page.
});
});
The result is not being passed to my PHP page, and instead being sent as not set. Let's say the users total hours were updated on the screen to 500 before submitting the form, I would expect this to return 500 but instead is returning 1.
$total_hours = isset($_POST["numberOfHours"]) ? $_POST["numberOfHours"] : '1';
numberOfHours html input:
<input type="number" class="form-control" name="numberOfHours" id="numberOfHours" value="0" disabled="disabled" />
Could someone shed some light on what is happening behind the scenes that is forcing the value to not be passed along