Home › Forums › Quform WordPress › Calculate date difference
Hello, I’ve followed the tutorial for calculations
Calculations
I’m trying to return the days difference between tow dates. This is the code I have got so far in the HTML element of my form:
<div id=”form-total”></div> <script> jQuery(document).ready(function ($) {
var startDate = new Date($(‘.iphorm_2_1’).val()); var endDate = new Date($(‘.iphorm_2_2’).val()); var diff = parseInt(startDate – endDate);
var calculate = function () { var total = Number(diff);
// Display the result to the user $(‘#form-total’).text(‘Total: $’ + total);
};
// Calculate on page load calculate();
// Recalculate when these select menus are changed $(‘.iphorm_2_1’).change(calculate); $(‘.iphorm_2_2’).change(calculate);
}); </script>
This is returning NaN, what am I doing wrong? Thanks in advance
You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
Working good, thank you.