kiwistag
asked on
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
I.E
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
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
I.E
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
var d=new Date();
d.setFullYear(YYYY,MM-1,DD
document.write(d,'<br \>');
d.setDate(d.getDate()+30);
document.write(d);
</script>
Note that month is zero based - 0=January