Skip to main content

I'd like to set the value of a yes/no control on a Nintex form using JQuery and for some reason I'm not able to get the result.

To evaluate the result, I'm using the Nintex rules. (Also tried this with a lookup calculated value control with the same results)

Let's say that the yes/no control is called Draft. The validation rule would then be:

Draft

(given that this is a yes/no control, this evaluates to true/false and nothing else is necessary)

After giving the control the javascript id Draft I've tried:

NWF$("#"+Draft).val("Yes");

(and variations of yes - "Yes","yes","True","true","1",1

I've also tried setting the prop and attr

NWF$("#"+Draft).prop("checked",true); and NWF$("#"+Draft).attr("checked",true);

While visually, the prop "checked" the checkbox, it didn't impact the validation rule.

So my question is, how to set the value of a yes/no control that that the nintex validation rule recognizes the value correctly?

Thanks,

Ok, I've figured out why. I need to trigger the change event - .trigger('change") or simply use .click() to toggle the value.


Hi Jan. I've been struggling with this exact problem since I'm relatively new to JS. Can you post the JS code showing the full syntax of the .trigger('change') or .click() you're using. The syntax is killing me and usually I'm missing a quote or period somewhere.

Thanks,

Gary


No worries, the absolute simplest way to change the value of the yes/no control is call the .click() event on it.

So let's say you have a y/n control with the nintex id being Draft (as in my example)

NWF$('#'+Draft).click();

This will toggle the value so if it was a no by default, it'll now be yes, and vice versa.

Now if you actually want to set it to a specific value regardless of what it was before you just need want to evaluate the current value.

function YourFunction(){

   var chk = NWF$('#'+Draft).prop('checked');

   if(chk){

      NWF$('#'+Draft).click();

   }

}

Hope this helps happy.png


Thanks for the good info Jan.


Reply