Skip to main content

Hello Team,

I am trying to reset a dropdown control based in a checkbox, I would like you to check my code and give me some feedbacks, I have done something similar in Nintex on-premisses but this solution is not working for nintex form 365...

 

Here is the script that I am using:

 

NWF$(document).ready(function(){ var obj = NWF$("#" +Driverc); obj.change(function(){NWF$("#" + Transporttoc).val('');} );} );

 

210279_pastedImage_3.png

The checkbox driver appear if the option "From Airport to Hotel" is selected in the dropdown, otherwise desappear.

Now what I need is: If checkbox has been selected and then the user realized that is not necesary and uncheck it, then reset the dropdown.

 

Thanks in advance

Hi,

The code you provided should work in my opinion... To be sure, that the dropdown gets reset only when checkbox is unchecked, you can add a rule to be verified:

NWF$(document).ready(function () {
    NWF$("#" + Driverc).change(function () {
        if (!NWF$(this).prop('checked'))
            NWF$("#" + Transporttoc).val('');
    });
});‍‍‍‍‍‍

Alternatively you can try to clear your dropdown selection using:

NWF$("#" + Transporttoc + " option:selected").removeAttr("selected");

But I think the "val('')" is enough.

Regards,

Tomasz


Hello

Thank you for your answer,

Is weird, now i am getting the error "The App Nintex Forms for Office 365 is out of date". Please update it.

I am not sure if I need make any update or something like that... Is the first time that I run into. 


Maybe try to refresh the window. I personally haven't seen anything like that ever

regards,

Tomasz


Hello,

You'll get that error whenever something is "wrong" with the Javascript.   It is usually syntax related.


Hey Tomasz

How would the code look like if the checkbox is a choice instead?

I been trying to use this:

NWF$(document).ready(function()
{
var freightChoice = NWF$("#" +FreightCharges);
freightChoice.change(function()
{
NWF$("#" + showProjectNumbers + " option:selected").removeAttr("selected");
} );
} );

the FreightCharges is the choice of 4 options and I like the dropdown field (showProjectNumber) to be reset as soon as the choice options have changed. If I get this to work then I will add more fields to reset based on same principle ...

the above code, does not work  


UPDATE

The script works when setting "Cliend ID JavaScript variable name" to YES and referencing it!

However, the dropdown field does not default back to its original state ...

Also tried with the below code but not working:

NWF$("#" + Transporttoc + " option:selected").removeAttr("selected");

Any suggestions?


UPDATE:

Finally got it to work as I wanted

NWF$(document).ready(function()
{
var freightChoice = NWF$("#" +FreightCharges);
freightChoice.change(function()
{
NWF$('#'+selectProjectNumbersValue).val("");
NWF$('#'+selectProjectNumbersValue).siblings('select.nf-client-control').val('**SelectValue**');

} );
} );

This now resets the dropdown value to "Please select..." for a vLookup field.

If you have a normal dropdown field then you need to implement the following:

NWF$("#" + selectProjectNumbersValue + " option:selected").removeAttr("selected");

source: https://community.nintex.com/thread/17642-is-it-possible-to-clear-value-of-lookup-column


Reply