Skip to main content
Nintex Community Menu Bar

Hi,

Trying to setup a Classic Nintex form that have Yes/No control that I want to set automatically based on the result of my calculated value of true or false. It mean when the result of my calculated value is “True” it will put check mark on the Yes/No box. Is this possible? I see some java script available that can do it but for some reason it is not working.

Here is my code:

NWF.FormFiller.Events.RegisterAfterReady(function () {var calculatedValueControl = NWF$('#' + MyCVID);calculatedValueControl.on('change', function () {var calculatedResult = NWF.RuntimeFunctions.Get  CalculatedValue(MyCVID);var yesNoControl = NWF$('#' + MyYesNoID);if (calculatedResult === true || calculatedResult === 'Yes') {yesNoControl.prop('checked', true);} else {yesNoControl.prop('checked', false);}});

 

Greatly appreciated any help.

Thank you.

Hi,

The following code should do the job.
It will check the box based on a true or false value from a calculated value control.
This happens on form load and then on value change.

 

NWF.FormFiller.Events.RegisterAfterReady(function () {

    function syncCheckbox() {
        var val = NWF$("#" + MyCVID).val();
        if (val === "true") {
            NWF$("#" + yesNoControl).prop("checked", true);
        } else {
            NWF$("#" + yesNoControl).prop("checked", false);
        }
    }

    syncCheckbox();

    NWF$("#" + MyCVID).change(function () {
        syncCheckbox();
    });
});

 


Hi SImon,

Thank you for your response. 

Just want to clarify on where I can put the Yes/No control in the code? I see you have for the Calculated Value which is the “MyCVID”, how about a reference to the yes/no control field?

 

Much appreciated.


I tried to code but it is not working, please see result screenshot. The true that was circled was the result of my calculated value and for some reason the Initial Freight checkbox was not mark.

 


Hi ​@aorellano,

You also need to assign a Client ID JavaScript variable name to the checkbox.
Please see my example form attached.