How to display dates dynamically

varunkumar1
Tera Contributor

Hi,

I have a requirement explained as below.

I have 3 date fields say (Date A, Date B and Date C) on a form. Based on date selected on Date A, the dates should be set in Date B and Date C.

For Ex: If I select Date A as today(03/17/2017) , then Date B should be set with yesterday's date(03/16/2017) and Date C should be set with "day before yesterday's date" (03/15/2017).

Please help me how can we do this.

12 REPLIES 12

So, first of all - you need to have these three date fields. So, immagine these are your fields:



Date A [ u_date_a ]


Date B [ u_date_b ]


Date C [ u_date_c ]



find_real_file.png


And they are of "Date" type.



In order to make your logic happen - one of possible ways is to leverage Ajax that would trigger server-side logic and return calculation.


Here is one good example: Client Script Date/Time Functions



Then, when you have that server-side logic, we need to write onChange client script that would call the logic and after getting response - it would change other field.


To do that - we create following client script:



find_real_file.png



So - come up with the name you want and enjoy results. Now, every time I change Date A - Date B automatically changes to +1 day:



find_real_file.png



Hope it was helpful. You can do the same to Date C field if you need and if you want to set days earlier - just add minus before number of days you wanna add.


Thanks Andrii,



Could you please send me the script include code that should be used for the above one.


Hi,



I actually already provided you with everything you need and even more. Community is about getting help, not doing job instead of someone else =(.


So what you need now is to pay attention to what you've been provided with and enjoy it.


Hi Andrii,



Thanks for the help.


I am able to set the value in Date B field based on Date A. Now I also want to set the value in Date C along with Date B, how can we achieve this.


Please let me know.


Add another Client Script with only difference - replace Date B with Date C and change delta(addtime) that you want to add/remove