Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

add a day to the value 1

Status
Not open for further replies.

onressy

Programmer
Mar 7, 2006
421
CA
Hi this is what i have:

var a1 = document.bookform.StartDate.value;
a1 = a1 +
document.bookform.EndDate.value=;

I'm trying to add a day to the date value and set it equal to document.bookform.EndDate.value

any suggestions?
 
sorry, here is my ill attempt:
Code:
var a1 = (document.bookform.StartDate.value)+1;
a1 = a1[date.getDay() + 1]
document.bookform.EndDate.value=a1;
 
You'd need to build up you output string depending on the format you want. You can add a day to the start date like this:

Code:
var frm = document.forms['bookform'].elements;
var msecsInADay = 86400000;
var startDate = new Date(ftm.StartDate.value);
var endDate = new Date(startDate.getTime() + msecsInADay);

and then use this to build up your output string if, for example, you wanted the end date to be formatted dd/mm/yyyy:

Code:
frm.EndDate.value = endDate.getDate() + '/' + (endDate.getMonth()+1) + '/' + endDate.getFullYear();

Hope this helps,
Dan

Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
sry, that was helpful, I ended up creating a function, and doing it in client side VB. very simular in theory. Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top