Enable/Disable Lookup & check/uncheck checkbox through Javascript

  • 23 November 2016
  • 5 replies
  • 106 views

Badge +2

Hi everybody,

I'm trying to enable/disable a lookup control through Javascript, this code works on text and choice controls:

//Option 1

NWF$("#"+controlID).attr('disabled','disabled');

NWF$("#"+controlID).removeAttr('disabled');

//Option 2

NWF$("#"+controlID).prop("disabled", true);

NWF$("#"+controlID).prop("disabled", false);

However, the code I posted above doesn't work on lookups.

Do you have any idea?

I'd also like to know how to check/uncheck a checkbox, I use the following code:

NWF$("#"+myCheckID]).prop('checked', true);

NWF$("#"+myCheckID]).prop('checked', false);

The checkbox is checked/unchecked, but the value doesn't change.

I connect the checbox to a calculated control, and the value is always the same (true/false), no matter if the checkbox is checked/unchecked.

I work with Nintex Forms 2013 2.9.3.1.

Thanks in advance.


5 replies

Userlevel 5
Badge +14

for lookup control try

NWF$("#"+controlID).closest('.nf-filler-control-border').prop("disabled", true);

reg. checkbox, is it yes/no checkbox or choice control with multiselect checkboxes?

Badge +2

Hi Marian,

I tried the code you suggested,it didn't work.

Regarding the checkbox question, yes, it is a reg. checkbox.

Thanks a lot.

Userlevel 5
Badge +14

I've tested it on my own before I posted it here and it worked for me.

how does evaluate following for you

NWF$('#'+controlID).closest('.nf-filler-control-border').length;
NWF$('#'+controlID).length‍‍;

for check box try

NWF$('#'+myCheckID).click();
Badge +2

Hi Marian,

I' ve tried again, and both solutions worked perfectly. Thanks for your help.

I have to redo all the code I use to handle lookups, do you know how to select a lookup option?

This code worked in the older Nintex Forms versions:

NWF$("#"+lookupID).val("myvalue");

I was also able to append and remove options:

NWF$("#"+lookupID).append("<option value='" +ID+ "'>" + Value+ "</option>");

NWF$("#" +lookupID + " > option[value='" + ID + "']").remove();

None of this code is working now. Do you have any documentacion or code example you could share?

Thanks in advance.

Userlevel 5
Badge +14

glad you get it working.

with the lookups there were significant changed in recent releases.

unfortunately, I'm not on the most recent forms version yet, so I do not know what exactly changed and how make it working again.

Reply