[NINTEX FORM] trigger filling a Date/Time with Javascript depending of Choice Control

  • 23 August 2016
  • 3 replies
  • 13 views

Badge +3

Hello,

I know there is some related topic with JS on this forum and out there on the internets but I don't manage to understand enought and implement what I want by myself. Hence I am turning to you, readers wink.png

I have a form, with a Control Setting Choice that I use to have the status of my items (Work in Progress, Closed, Input Rejected)

I have also a  Control Setting Date/Time that I use to store the date and time when the item go in status closed.

At the moment the date is manually inputted but I want that the date is automatically populated when user select status=Closed and I still want to have the possibility to change the date afterward (Else I would have just putted the date into a variable and linked the variable to the date field)

So when user change the status to "Closed", JS shall be triggered and populate the date field with the current date and time.

Could any guide me how to achieve that. I understand JS a bit but I am not familiar at all with how to write it, what to call with NWF$ etc,...

I assume the function shall be stored into the Form custom JS and that it is triggered by the JS validation on the Choice control?


3 replies

Badge +11

Hi Romain condat

There are resources on the community for this. Setting current date and time on control

In the drop down control, choose custom validation yes, and add the name of the javascript function. setDateTime()

Assign the Client ID JavaScript variable name to the date picker.

Badge +3

Hi Kapil,

I managed to display a part of the date like I want (atm the minutes are not working properly but I am confident in finding what is wrong), so it is a start.

But how only trigger the JS depending the when my Choice field is = Closed.

Shall I put an Client ID on the choice control and in the JS function have something like:

If ClientIDStatus=Closed* then do stuff, else exit ?

How to translate this into JS?

Badge +11

Hi,

Yes, you have to assign a client ID javasctip variable to the drop down control say choiceVal. You can first get the value of the drop down and depending on the value run the function.

Inside the javascript function check the value....

function setDateTime()

{

var sel = NWF$('#' + choiceval).val();

if(sel == "Closed"){

....ADD your code here....

}

}

This function will execute the statements only when the selected choice is Closed.

Reply