The following is amended to correctly subtract the number of days from the current date (to handle change of month).
Code:
function printDate(offset) {
var offsetAmount= offset.value
var currentTime= new Date()
currentTime.setDate(currentTime.getDate() - offsetAmount);
var month= currentTime.getMonth() + 1
var day= currentTime.getDate()
var year= currentTime.getFullYear()
document.write(nDay + "/" + month + "/" + year)
}
The other thing you need to look at is that document.write can only be used before the page finishes loading so you if it is goint to be run after that then you also need to replace that line either with an innerHTML call to update a part of the current page or by using the DOM methods to add the extra field into the page.
Bookmarks