Set date (end date = start date)

  • 18 July 2017
  • 5 replies
  • 10 views

Badge +10

Hi everybody,

I have a form where the user is asked to give a start and an end date.

After giving the start date, the end date should be prepopulated with the start date, whereas this should still be editable.

Cheers,

mai-kel


5 replies

Badge +9

Hi ‌,

Try this JS code.

NWF$('#'+Date1).change(function()
{
var date=NWF$('#'+Date1).datepicker('getDate');
NWF$('#'+Date2).datepicker('setDate', date);    
});

Thanks,

Lakshmi C

Badge +10

Great. That's it! Thanks a lot buddy! grin.png 

Badge +3

Hi Lakshmi C 

I'm new in Nintex. Can you please provide the steps to apply this JS code in Nintex form?

I've tried paste the code in Setting - Form > Custom JavaScript Box 

And change the code as below but it doesn't work.

NWF$('#'+VisitStartDateTime).change(function()
{
var date=NWF$('#'+VisitStartDateTime).datepicker('getDate');
NWF$('#'+VisitEndDateTime).datepicker('setDate', date);   
});

Thanks,

Emily

Badge +10

Step 1:
Create first date / time control.
Go to advanced settings and configure
- "Store Client ID in JavaScript variable" -> yes
- "Client ID JavaScript variable name" -> Date1


Step 2:
Create (second) date / time control.
Go to advanced settings and configure
- "Store Client ID in JavaScript variable" -> yes
- "Client ID JavaScript variable name" -> Date2

Step3:
Go to form settings.
Open "Advanced", insert the following code into "Custom JavaScript Includes":

NWF$('#'+Date1).change(function()
{
var date=NWF$('#'+Date1).datepicker('getDate');
NWF$('#'+Date2).datepicker('setDate', date);    
});

Badge +3

It worked Michael, thanks.

Reply