How to display dates dynamically
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2017 08:02 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2017 10:38 AM
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 ]
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:
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:
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-18-2017 02:02 AM
Thanks Andrii,
Could you please send me the script include code that should be used for the above one.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-18-2017 02:13 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-18-2017 11:05 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-18-2017 11:22 PM
Add another Client Script with only difference - replace Date B with Date C and change delta(addtime) that you want to add/remove