I am looking to calculate the differences between two dates. I will input the date values in the text box and want the duration to be displayed in another text box.
<script language=javascript>
function formshowhide(id) {
if (id == "other") {
//document.getElementById('quotef').style.display = "block";
document.getElementById('otherf').style.display = "block";
//Function to calculate duration
var txtdate1 = document.getElementById('MainContent_txtOStartDate').value;
var txtdate2 = document.getElementById('MainContent_txtOEndDate').value;
var date1 = new Date(txtdate1.split('-')[0], txtdate1.split('-')[1] - 1, txtdate1.split('-')[2]);
var date2 = new Date(txtdate2.split('-')[0], txtdate2.split('-')[1] - 1, txtdate2.split('-')[2]);
var timediffsec = date2.getTime() - date1.getTime();
var timediffday = parseInt(timediffsec / (24 * 3600 * 1000));
document.getElementById('MainContent_txtDays').value = timediffday;
//End of duration calculation function
}
else {
// document.getElementById('quotef').style.display = "none";
document.getElementById('otherf').style.display = "none";
}
}
</script>