Link to home
Start Free TrialLog in
Avatar of taborrg
taborrg

asked on

Need to add days to a date in javascript.

Hi,

I'm need to add days to a date in javascript.  Here's the code I've been trying:

      departure = dateCheck_in.setDate(dateCheck_in.getDate() + 10);
      
Thanks
Avatar of Gary
Gary
Flag of Ireland image

And the problem is? The code is correct
Avatar of taborrg
taborrg

ASKER

Here's more of the code:

       alert(departure);
      departure = dateCheck_in.setDate(dateCheck_in.getDate()+ 10);
      alert(departure);
      document.getElementById('check_out_date').value= departure;

The first alert works, the second does not occur, and the departure value does not go into the 'check_out_date' textbox.

Thanks
Have you set dateCheck_in as a DATE
var dateCheck_in = new Date();
Avatar of taborrg

ASKER

I get it from a textbox with a dropdown calendar:

          var dateCheck_in = document.getElementById('check_in').value;

It shows up if I set an alert to display it.
ASKER CERTIFIED SOLUTION
Avatar of Gary
Gary
Flag of Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of taborrg

ASKER

Works perfect!

Thanks.
Avatar of taborrg

ASKER

Thanks!