|
Hi Guys,
I'm trying to increment a date field by X number of days.
X is captured by a prompt and stored in variable [dateday].
The field on the form is called ExpiryDate
My function is working, but it is replacing ExpiryDate's value with TODAY's date incremented by X instead of ExpiryDate's existing value incremented by X.
To summarise, I have this field on a form.
It might have a value of 21/04/2004
When prompted I type in a number... say 2 to increase expirydate by 2 days.
Expiry date gets replaced with 17/04/2004 (today - 15th, plus 2) instead of 23/04/2004 (expirydate's value plus 2)
Here is script buddy..... hope you can help! think I need to do somthing with the var time = new Date() line??
Gonzo
function ExtendDate(){
var time = new Date();
var dateday = prompt("Please enter number of days to increase expiry date
by","");
days =parseInt(dateday);
time.setTime(time.getTime()+days*24*60*60*1000)
var day = time.getDate();
var month =parseInt(time.getMonth()+1);
var year = time.getYear();
if (dateday != null && dateday != "")
{
alert("This will increase date object by " + dateday + " days!");
document.forms[0].ExpiryDate.value=day+'/index.html'+month+'/index.html'+year;
}
}
|
|
|
|
|
|
|
|