Checkboxes can no loger be checked/selected programmatically after clearing them


Badge +3

Hello!

 

I am creating an order form and have custom JavaScript functions that check checkboxes based on the bundle selected.

Checking those boxes work without problems.

When the bundle is changed, I want to clear all boxes first, then check the appropriate boxes for the new bundle selected.

 

My problem: When the checkboxes are cleared, either by the “clearAllCheckboxes()” function or manually, the checkboxes can no longer be checked programmatically. What am I missing?

 

Here is my code:

//COMPUTER BUNDLE =====

 

function populateSalesBundle(){

NWF$('#'+varLaptop).find('input[value='Laptop']').attr('checked', 'checked');

NWF$('#'+varLTCase).find('input[value='Case']').attr('checked', 'checked');

NWF$('#'+varCableLock).find('input[value='Cable Lock']').attr('checked', 'checked');

};

 

function populateExecutiveBundle(){

NWF$('#'+varDesktop).find('input[value='Desktop']').attr('checked', 'checked');

NWF$('#'+varLaptop).find('input[value='Laptop']').attr('checked', 'checked');

};

 

function populateWorkFromHomeBundle(){

NWF$('#'+varLaptop).find('input[value='Laptop']').attr('checked', 'checked');

NWF$('#'+varKeyboard).find('input[value='Keyboard']').attr('checked', 'checked');

NWF$('#'+varDockingStation).find('input[value='Docking Station']').attr('checked', 'checked');

NWF$('#'+varLTCase).find('input[value='Case']').attr('checked', 'checked');

NWF$('#'+varCableLock).find('input[value='Cable Lock']').attr('checked', 'checked');

NWF$('#'+varDTMonitor).find('input[value='Monitor']').attr('checked', 'checked');

NWF$('#' + varDTMonitorQty).val(2);

};

 

function clearAllCheckboxes(){

NWF$('input[type=checkbox]').prop('checked', false);

};

 

//END COMPUTER BUNDLE SECTION=====


4 replies

Userlevel 5
Badge +14

I would say the problem is you mix prop() and attr().

use prop() everywhere.

Badge +3

Thank you so much for your quick reply. I will try that.

I am very new to Nintex and I just copy codes that I find online

Userlevel 5
Badge +14

laugh.png

Badge +3

Much thanks, Marian! That change from "attr" to "prop" made the script work.

Reply