cancel
Showing results for 
Search instead for 
Did you mean: 
lgiambar
Nintex Newbie

set date and time with drop down

Is it possible to set a date and time field on a Nintex form based on a value in a drop down? 

If Completed in selected in the status field, we want the date and time to populate to the current date and time.

any help?

Thanks!

0 Kudos
Reply
3 Replies
lakshminarayana
Nintex Newbie

Re: set date and time with drop down

Try this.

NWF$(document).ready(function()
{
 NWF$('#'+dropdown).change(function()
 {
  fnSetDate();
 });
});
function fnSetDate()
{
 var dropdownvalue = NWF$('#'+dropdown).val();
 alert(dropdownvalue);
 if(dropdownvalue == 'Completed')
 {
 var fullDate = new Date();
 var twoDigitMonth = ("0" + (fullDate.getMonth() + 1)).slice(-2);
 var hours = fullDate.getHours();
 var minutes = fullDate.getMinutes();
 var currentDate = fullDate.getDate() + "/" + twoDigitMonth + "/" + fullDate.getFullYear();
 if (hours < 10) { hours = "0" + hours; }
 minutes = minutes - 2.5;
 minutes = 5 * Math.round( minutes / 5 );
 NWF$('#' + fldDateClosed).val(currentDate);

 NWF$('#' + fldDateClosed+ " + IMG + SELECT").val('10 AM');
 NWF$('#' + fldDateClosed+ " + IMG + SELECT + SELECT").val('45');
 }
}

0 Kudos
Reply
lgiambar
Nintex Newbie

Re: set date and time with drop down

Do i just put that code into the custom javascript field on the settings of the form? Does this update before or after save?

0 Kudos
Reply
lakshminarayana
Nintex Newbie

Re: set date and time with drop down

Yes you need to copy this code in 'Form Settings' under 'Custom JavaScript'. When you change 'Status' drop down value based on selected value this will set current date and time to your date control.

Give names like 'fldDateClosed' to 'Date control' and 'dropdown' to 'Status' like below in your control settings.

0 Kudos
Reply