Skip to main content
Nintex Community Menu Bar

set date and time with drop down

  • Oct 30, 2017 9:11 PM UTC
  • 3 replies
  • 46 views
  • Translate All

Forum|alt.badge.img+7

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!

210205_pastedImage_1.png

3 replies

Forum|alt.badge.img+9

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');
 }
}

Translate

Forum|alt.badge.img+7
  • Author
  • Nov 1, 2017 4:55 PM UTC

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

Translate

Forum|alt.badge.img+9

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.210312_pastedImage_1.png

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

210313_pastedImage_2.png

Translate