Feel like I am out of my depth here. Moreover, similar questions posted on this site tend to show only a code snippet - not helpful for beginners or keep referring to adding days to today's date, which is not entirely helpful to me either. I have a form which requires the user to enter the Number of days they wish to borrow an item and a date they wish the loan to commence. The latter may be written in the following format 01/12/2015. How do a write a function to get the return date and display it in the form? This is what I have so far
function ReturnDate(){ // code indentation
var reservationStart = document.getElementById('reservationStart').value;
var requestedDays = parseInt(document.getElementById('days').value);
var returnDate = document.getElementById('DateEnd');
myResult = Date.setTime(reservationStart.getTime() + requestedDays* 86400000);
DateEnd.value = myResult;
}
Nor am I entirely sure why we multiply by 86400000
As requested, please find the HTML code:
<tr>
<td>Number of days</td>
<td><input type="text" name="days" id="days" onkeyup="calculate()" placeholder= "Enter the number of days you wish to borrow the game for" autocomplete="off" style="width:80%" /></td>
</tr>
<tr>
<td>Date start <i>(dd/mm/yyyy)</i></td>
<td><input type="text" value="" name="reservationStart" id="reservationStart" onkeyup="ReturnDate()" style="width:80%"/></td>
</tr>
<tr>
<td>Date end</td>
<td><input type="text" value="" name="DateEnd" id="DateEnd" style="width:80%"/></td>
</tr>
reservationStartelement would be helpful.