This topic is locked

Add Days To Date Automatically - Javascript

7/15/2020 9:19:51 AM
PHPRunner General questions
C
copper21 author

Hello All,
Looking for a little guidance...this is probably pretty easy, but just can't figure it out. I read the article regarding how to calculate totals on the fly, was looking for some inspiration to simply add a number of days to a date using Javascript on the add page...this should be done on the fly. I have a field that you can put a number of days in, then a field that you enter a date in, looking to add the number of days in the first field to the date entered in the second field to automatically fill the third field with a new date.
Fields:
NumberOfDays

StartDate

EndDate
For example I would enter 10 in the number of days field, then enter 7/1/2020 in the start date field, and then I need it to populate the end date field automatically with 7/11/2020.
Thank you in advance for your help!

Admin 7/15/2020

Check this article for inspiration:

https://stackoverflow.com/questions/3818193/how-to-add-number-of-days-to-todays-date
You will need to convert the date value to Date object first and then use the suggested code from the article to add days to the date.