Javascript auto update date field for duration

Similar to: Javascript date function to calculate the end date using the duration

I have a website & need part of the form to autocalculate the end date (30 days from the entry date) after the month field has been entered.

The fields in use are StartDD, StartMM, StartYYYY.

At present I have the input text fields linked with auto clear & auto-hop
Start Date: (DD) - (MM) - (YYYY)
Jumping into DD will clear the DD text, typing in 2 numbers in DD will jump it into the MM box & so on.

At present the YYYY field is auto-populated however this may have to change at the end of the year.

Any helps with examples would be great
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

<script type="text/javascript">
var d=new Date();
document.write(d,'<br \>');

Note that month is zero based - 0=January
To make it easier, here's a function:
function addDays(YYYY,MM,DD,Days)
var d=new Date();

Open in new window

call it with
updateDate(YYYY,MM,DD,30) to add 30 days.
updateDate(2011,3,28,30) for example.

You can also enter a  negative number to get a date in the past.  

This function will work across year boundaries as well, so there's no need to worry about changing your code as you approach the end of the year.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cut and paste error above, in development I saw calling the function updateDate and changed it to addDays, before I pasted it in.  Clearly, the function addDays is called using the function name addDays rather than updateDate. I apologize for the error.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Languages and Standards

From novice to tech pro — start learning today.