How to set a Date Field in dependence of another Date Field and adding additional days
Hello together,
i want to set the date field of "Vertragsende" to a specific date which is 365 days later then the date field "Gewünschter Vertragsbeginn". The problematic is that to the start of the form the starting date isnt known yet. The user needs to select a starting date first.
Does anyone know how i can accomplish this?

-
I believe both the date fields you have in same form and the functionality should be once the first date is selected , the other date should be automatically get selected based on the calculation. (first date + 365 days )
We can achieve this using java script code . We can write a java script method which will do the calculation based on the selection of First date and input for how many days you want to add .
In the configuration window of Start Date on Change Event, you can call the above java script method . So this will trigger the method to calculate the new date every time you change the Start Date
So as per your requirement above , you want to add 365 days , which is like 1 year will get added to the selected date .
If you want to add few months or few dates , the calculation logic will change accordingly .
Here is a sample code snippet to achieve this .
function addExtraDateToDependentDateField() { var startDate= $('#StartDate').val(); var fUllDate= new Date(startDate); var date= (fUllDate.getDate()) <= 9 ? "0" + (fUllDate.getDate()) : (fUllDate.getDate()); var month = (fUllDate.getMonth()) <= 9 ? "0" + (fUllDate.getMonth()) : (fUllDate.getMonth()); var year = fUllDate.getFullYear() + 1; // 365 days is 1 year var endDate = month + "/" +date + "/" + year; $('#EndDate').val(endDate); }
Here is screenshot of the above code result.
Thanks
Roupya
请先登录再写评论。
评论
1 条评论